named CPU models for Arm64 on KVM
Subsystems (2)
v3 cover named CPU models for Arm64 on KVM
Hi All,
This is v3 of the RFC adding named CPU model support for Arm64 in QEMU. The main change in this revision is that the series is now rebased on top of Eric Auger's "customizable host model" series [1], and adopts its per-field SYSREG_<REG>_<FIELD>=<u64> property convention. v3 also scales back a lot from v2 in terms of added "stuff", removing the concept of "composites" and the support for exposing cache information to the guest.
Background:
=============================================================
Currently QEMU only supports -cpu host/max for KVM on Arm64. This blocks live migration of VMs between hosts that differ in CPU features.
This RFC proposes hierarchical named models for Arm64 under KVM. A named model is a strict contract of the CPU features exposed to the guest, so the same model resolves to the same guest-visible ID registers on any capable host. Models can be customized further by overriding individual ID-register fields (e.g. SYSREG_ID_AA64ISAR0_EL1_SHA1=0).
On top of the models, this series adds the QMP introspection support on Arm that the management layer already depends on for x86:query-cpu-definitions lists the models a host can run and reports blockers for the ones it cannot, query-cpu-model-expansion resolves a model to its full set of properties, and the new query-cpu-props-info reports the values the host supports for each property. The aim is feature parity with x86 so existing tooling can consume Arm named models with little change.
TL;DR examples:
=============================================================
# Boot a named model
qemu-system-aarch64 -cpu grace-v1 -machine virt,accel=kvm ...
# Named model with ID-register field override qemu-system-aarch64 -cpu grace-v1,SYSREG_ID_AA64ISAR0_EL1_SHA1=0 ...
# -cpu host with ID-register field override qemu-system-aarch64 -cpu host,SYSREG_ID_AA64ISAR0_EL1_AES=1 ...
# query-cpu-model-expansion
"model": {
"name": "graviton3-v1",
"props": {
"SYSREG_ID_AA64ISAR0_EL1_AES": 2,
"SYSREG_ID_AA64ISAR0_EL1_SHA1": 1,
"SYSREG_ID_AA64ISAR0_EL1_SHA2": 2,
"SYSREG_ID_AA64ISAR1_EL1_APA": 3,
"SYSREG_ID_AA64PFR0_EL1_SVE": 1,
"sve": true,
"sve128": true,
...
}
} # query-cpu-definitions: blockers reporting
{
"name": "graviton3-v1",
"typename": "graviton3-v1-arm-cpu",
"unavailable-features": [
"SYSREG_ID_AA64MMFR0_EL1_TGran16_2",
"SYSREG_ID_AA64MMFR0_EL1_TGran64_2",
"SYSREG_ID_AA64MMFR0_EL1_TGran4_2",
"SYSREG_ID_AA64ISAR1_EL1_APA",
"SYSREG_ID_AA64ISAR0_EL1_SM3",
"SYSREG_ID_AA64ISAR0_EL1_SM4"
],
"static": false,
"deprecated": false
}
# new query-cpu-props-info: supported values per property
{
"name": "SYSREG_ID_AA64ISAR0_EL1_AES",
"supported-values": [
{ "min": 2, "max": 2 },
{ "min": 1, "max": 1 },
{ "min": 0, "max": 0 }
],
"type": "number"
},
{
"name": "sve",
"supported-values": [ true, false ],
"type": "boolean"
}Planned Items for v4:
- Strict forward compatibility: Right now a model is only safe against a newer host if QEMU happens to know the new ID registers. We can close that gap: the fields we care about live in the Feature ID space (ID_AA64PFR0_EL1 and friends), and the architecture already guarantees unallocated encodings there RES0 - "Direct reads [...] behave as Reserved, RES0 [...] if the encodings are used for ID registers in the future" (DDI 0487M.a, D23.3). So any feature ID register that QEMU does not know about must be "0" or enforced to "0" if writable by KVM.
- Special-case handling for CNTFRQ_EL0: make sure heterogeneous migration does not happen between hosts with different CNTFRQ_EL0 values.
- Remove RESx properties.
- Both series struggle with how SYSREG_ properties interact with already-defined QEMU properties like pauth/sve/pmu etc. We can solve this by verifying that the cmdline property values match the user-given values after we finalize the properties (something like enforce in x86?).
Khushit Shah (18):
target/arm/sysreg: regenerate cpu-sysregs.h.inc
scripts: bug fixes in update-aarch64-cpu-sysreg-properties target/arm: regenerate cpu-idregs.h.inc
target/arm: expose all ID regs fields as properties target/arm/kvm: enable writable implementation ID registers target/arm/kvm: Read all ID registers from KVM target/arm/kvm: handle special ID registers cases when reading from
KVM
target/arm/kvm: Handle writeback for special ID register fields target/arm: Add Nvidia Grace named model
target/arm: fix sve and pauth finalize for named cpu models target/arm: Introduce stub files required for qmp support target/arm/qmp: add named models and properties to cpu-model-expansion target/arm/kvm: compute supported values for ID register fields target/arm/kvm: introduce kvm_arm_get_host_isar helper
qmp: add query-cpu-props-info command
target/arm: Report 0 as supported for ID fields gated by vCPU init
flags
target/arm/qmp: hook blockers in query-cpu-definitions target/arm/kvm: fix host model writeback when kernel supports EL2
Shaju Abraham (1):
target/arm: Add named cpu model infra + graviton3 named model
hw/arm/virt.c | 8 + qapi/machine.json | 87 +++ .../update-aarch64-cpu-sysreg-properties.py | 67 ++- stubs/meson.build | 1 + stubs/qmp-cpu-props-info.c | 12 + target/arm/arm-cpu-models-stub.c | 18 + target/arm/arm-cpu-models.c | 533 +++++++++++++++++ target/arm/arm-cpu-models.h | 37 ++ target/arm/arm-qmp-cmds.c | 111 ++++ target/arm/cpu-idregs.c | 19 + target/arm/cpu-idregs.h | 4 + target/arm/cpu-idregs.h.inc | 165 +++--- target/arm/cpu-sysregs.h.inc | 1 + target/arm/cpu64.c | 198 ++++++- target/arm/internals.h | 6 + target/arm/kvm-stub.c | 24 +- target/arm/kvm.c | 560 ++++++++++++------ target/arm/kvm_arm.h | 52 +- target/arm/meson.build | 8 +- target/arm/trace-events | 6 +- 20 files changed, 1594 insertions(+), 323 deletions(-) mode change 100644 => 100755 scripts/update-aarch64-cpu-sysreg-properties.py create mode 100644 stubs/qmp-cpu-props-info.c create mode 100644 target/arm/arm-cpu-models-stub.c create mode 100644 target/arm/arm-cpu-models.c create mode 100644 target/arm/arm-cpu-models.h
Signature · 1 line
2.52.0
RFC PATCH v3 1/19 target/arm/sysreg: regenerate cpu-sysregs.h.inc
--- target/arm/cpu-sysregs.h.inc | 1 + 1 file changed, 1 insertion(+)
target/arm/cpu-sysregs.h.inc +1 -0
@@ -19,6 +19,7 @@ DEF(ID_AA64FPFR0_EL1, 3, 0, 0, 4, 7) DEF(ID_AA64ISAR0_EL1, 3, 0, 0, 6, 0) DEF(ID_AA64ISAR1_EL1, 3, 0, 0, 6, 1) DEF(ID_AA64ISAR2_EL1, 3, 0, 0, 6, 2) +DEF(ID_AA64ISAR3_EL1, 3, 0, 0, 6, 3) DEF(ID_AA64MMFR0_EL1, 3, 0, 0, 7, 0) DEF(ID_AA64MMFR1_EL1, 3, 0, 0, 7, 1) DEF(ID_AA64MMFR2_EL1, 3, 0, 0, 7, 2)
Signature · 1 line
2.52.0
Re: [RFC PATCH v3 01/19] target/arm/sysreg: regenerate cpu-sysregs.h.inc
Hi Khushit,
Quoted 10 lines · Khushit Shah
Signed-off-by Khushit Shah <[email protected]>--- target/arm/cpu-sysregs.h.inc | 1 + 1 file changed, 1 insertion(+)target/arm/cpu-sysregs.h.inc +0
-0
target/arm/cpu-sysregs.h.inc DEF(ID_AA64FPFR0_EL1, 3, 0, 0, 4, 7) · line 22
Quoted 4 lines
target/arm/cpu-sysregs.h.inc +1
-0@@ -19,6 +19,7 @@ DEF(ID_AA64FPFR0_EL1, 3, 0, 0, 4, 7) DEF(ID_AA64ISAR0_EL1, 3, 0, 0, 6, 0) DEF(ID_AA64ISAR1_EL1, 3, 0, 0, 6, 1) DEF(ID_AA64ISAR2_EL1, 3, 0, 0, 6, 2) +DEF(ID_AA64ISAR3_EL1, 3, 0, 0, 6, 3)
Please could you send a branch. It is difficult to understand on which code base you applied thise series asID_AA64ISAR3_EL1 definition is already upstream
Thanks
Eric
Quoted 3 lines
target/arm/cpu-sysregs.h.inc +0
-0DEF(ID_AA64MMFR0_EL1, 3, 0, 0, 7, 0) DEF(ID_AA64MMFR1_EL1, 3, 0, 0, 7, 1) DEF(ID_AA64MMFR2_EL1, 3, 0, 0, 7, 2)
Re: [RFC PATCH v3 01/19] target/arm/sysreg: regenerate cpu-sysregs.h.inc
Quoted 17 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Hi Khushit,
Quoted 5 lines · Khushit Shah
Signed-off-by Khushit Shah <[email protected]>---
target/arm/cpu-sysregs.h.inc | 1 +1 file changed, 1 insertion(+)
Quoted 12 lines
target/arm/cpu-sysregs.h.inc DEF(ID_AA64FPFR0_EL1, 3, 0, 0, 4, 7) · line 22
Quoted 9 lines
target/arm/cpu-sysregs.h.inc +1
-0@@ -19,6 +19,7 @@ DEF(ID_AA64FPFR0_EL1, 3, 0, 0, 4, 7) DEF(ID_AA64ISAR0_EL1, 3, 0, 0, 6, 0) DEF(ID_AA64ISAR1_EL1, 3, 0, 0, 6, 1) DEF(ID_AA64ISAR2_EL1, 3, 0, 0, 6, 2) +DEF(ID_AA64ISAR3_EL1, 3, 0, 0, 6, 3)Please could you send a branch. It is difficult to understand on which code base you applied thise series as
ID_AA64ISAR3_EL1definition is already upstream
Ohh okay,
Please use the following branch:
https://github.com/khushit-shah-nx/qemu/tree/upstream-rfc-v3-fixups
Will rebase on top of master for v4.
Warm Regards,
Khushit
Quoted 9 lines
Thanks
Eric
Quoted 3 lines
target/arm/cpu-sysregs.h.inc +0
-0DEF(ID_AA64MMFR0_EL1, 3, 0, 0, 7, 0) DEF(ID_AA64MMFR1_EL1, 3, 0, 0, 7, 1) DEF(ID_AA64MMFR2_EL1, 3, 0, 0, 7, 2)
RFC PATCH v3 2/19 scripts: bug fixes in update-aarch64-cpu-sysreg-properties
In reply to Khushit Shah- handle quoted bitstrings and decimal
- skip Values.ValueRange entries.
- Emit unique RESx_{lsb} names for reserved fields so no two fields in a register share a name.
- Emit a dummy 64-bit VAL field for registers with no defined fields, such as AIDR_EL1 and REVIDR_EL1.
--- .../update-aarch64-cpu-sysreg-properties.py | 67 +++++++++++++------ 1 file changed, 45 insertions(+), 22 deletions(-) mode change 100644 => 100755 scripts/update-aarch64-cpu-sysreg-properties.py
scripts/update-aarch64-cpu-sysreg-properties.py +45 -22
@@ -106,6 +106,29 @@ def collect_fields(item, bit_offset=0): return fields +def parse_value_int(raw_val): + if raw_val is None or isinstance(raw_val, bool): + return None + + # may already be real number + if isinstance(raw_val, int): + return raw_val + + raw_str = str(raw_val).strip() + + if "'" in raw_str: + # quoted bitstring like "'0100'" + bits = raw_str.replace("'", "") + try: + return int(bits, 2) + except ValueError: + return None + + # unquoted, try decimal + try: + return int(raw_str, 0) + except ValueError: + return None def extract_field_enums(field): enums = []
@@ -124,32 +147,23 @@ def extract_field_enums(field): if not isinstance(val_entries, list): return enums + # A Values.ValueRange field specifies start and end value for a range. + # Don't enumerate anything for them. + for val_entry in val_entries: + if isinstance(val_entry, dict) and \ + val_entry.get("_type") == "Values.ValueRange": + return [] + for val_entry in val_entries: if not isinstance(val_entry, dict): continue - + if val_entry.get("_type") == "Values.Value": - raw_val = val_entry.get("value") - if raw_val is None: + int_val = parse_value_int(val_entry.get("value")) + if int_val is None: continue - - # some of the values have ' like "'0100'" - raw_val_str = str(raw_val).strip().replace("'", "") - - try: - # convert into bin - int_val = int(raw_val_str, 2) - except ValueError: - try: - # Fallback to dec if not bin - int_val = int(raw_val_str, 0) - except ValueError: - continue - - enums.append({ - 'value': int_val - }) - + enums.append({'value': int_val}) + return enums def generate_sysreg_properties_from_registers_json(id_reg_names, raw_json_path):
@@ -210,7 +224,7 @@ def generate_sysreg_properties_from_registers_json(id_reg_names, raw_json_path): msb > current_fieldset_fields[unique_key]['msb']: enums = extract_field_enums(val) current_fieldset_fields[unique_key] = { - 'raw_name': name, + 'raw_name': unique_key, 'lsb': lsb, 'msb': msb, 'width': width,
@@ -238,6 +252,15 @@ def generate_sysreg_properties_from_registers_json(id_reg_names, raw_json_path): # Sort decreasing lsbs sorted_fields = sorted(unique_fields.items(), key=lambda x: x[1]['lsb'], reverse=True) + if len(sorted_fields) == 0: + # cases like REVIDR_EL1 and AIDR_EL1. + # augment a dummy fields VAL. + sorted_fields.append(('VAL', { + 'lsb': 0, + 'msb': 63, + 'width': 64, + 'enums': [] + })) for unique_key, bits in sorted_fields: enums_list = bits.get('enums', [])
Signature · 1 line
2.52.0
Re: [RFC PATCH v3 02/19] scripts: bug fixes in update-aarch64-cpu-sysreg-properties
Quoted 2 lines · Khushit Shah
- handle quoted bitstrings and decimal
- skip Values.ValueRange entries.
The above is the issue you reported on my v6. See my comment on the other thread.
Quoted 2 lines
- Emit unique RESx_{lsb} names for reserved fields so no two fields in a register share a name.
The requirement for naming RES field needs to be explained. I understand that now you expose all fields including those which are not writable it may be required but at this stage I still fail why this is requested.
Quoted 2 lines
- Emit a dummy 64-bit VAL field for registers with no defined fields, such as
AIDR_EL1andREVIDR_EL1.
This is yet another functional change that could be separate.
Thanks
Eric
Quoted 113 lines
Signed-off-by Khushit Shah <[email protected]>--- .../update-aarch64-cpu-sysreg-properties.py | 67 +++++++++++++------ 1 file changed, 45 insertions(+), 22 deletions(-) mode change 100644 => 100755 scripts/update-aarch64-cpu-sysreg-properties.pyscripts/update-aarch64-cpu-sysreg-properties.py +45
-22@@ -106,6 +106,29 @@ def collect_fields(item, bit_offset=0): return fields +def parse_value_int(raw_val): + if raw_val is None or isinstance(raw_val, bool): + return None + + # may already be real number + if isinstance(raw_val, int): + return raw_val + + raw_str = str(raw_val).strip() + + if "'" in raw_str: + # quoted bitstring like "'0100'" + bits = raw_str.replace("'", "") + try: + return int(bits, 2) + except ValueError: + return None + + # unquoted, try decimal + try: + return int(raw_str, 0) + except ValueError: + return None def extract_field_enums(field): enums = []@@ -124,32 +147,23 @@ def extract_field_enums(field): if not isinstance(val_entries, list): return enums + # A Values.ValueRange field specifies start and end value for a range. + # Don't enumerate anything for them. + for val_entry in val_entries: + if isinstance(val_entry, dict) and \ + val_entry.get("_type") == "Values.ValueRange": + return [] + for val_entry in val_entries: if not isinstance(val_entry, dict): continue - + if val_entry.get("_type") == "Values.Value": - raw_val = val_entry.get("value") - if raw_val is None: + int_val = parse_value_int(val_entry.get("value")) + if int_val is None: continue - - # some of the values have ' like "'0100'" - raw_val_str = str(raw_val).strip().replace("'", "") - - try: - # convert into bin - int_val = int(raw_val_str, 2) - except ValueError: - try: - # Fallback to dec if not bin - int_val = int(raw_val_str, 0) - except ValueError: - continue - - enums.append({ - 'value': int_val - }) - + enums.append({'value': int_val}) + return enums def generate_sysreg_properties_from_registers_json(id_reg_names, raw_json_path):@@ -210,7 +224,7 @@ def generate_sysreg_properties_from_registers_json(id_reg_names, raw_json_path): msb > current_fieldset_fields[unique_key]['msb']: enums = extract_field_enums(val) current_fieldset_fields[unique_key] = { - 'raw_name': name, + 'raw_name': unique_key, 'lsb': lsb, 'msb': msb, 'width': width,@@ -238,6 +252,15 @@ def generate_sysreg_properties_from_registers_json(id_reg_names, raw_json_path): # Sort decreasing lsbs sorted_fields = sorted(unique_fields.items(), key=lambda x: x[1]['lsb'], reverse=True) + if len(sorted_fields) == 0: + # cases like REVIDR_EL1 and AIDR_EL1. + # augment a dummy fields VAL. + sorted_fields.append(('VAL', { + 'lsb': 0, + 'msb': 63, + 'width': 64, + 'enums': [] + })) for unique_key, bits in sorted_fields: enums_list = bits.get('enums', [])
Re: [RFC PATCH v3 02/19] scripts: bug fixes in update-aarch64-cpu-sysreg-properties
Quoted 11 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 5 lines
Quoted 2 lines · Khushit Shah
- handle quoted bitstrings and decimal
- skip Values.ValueRange entries.The above is the issue you reported on my v6. See my comment on the other thread.
Acked.
Quoted 5 lines
Quoted 2 lines
- Emit unique RESx_{lsb} names for reserved fields so no two fields in a register share a name.
The requirement for naming RES field needs to be explained. I understand that now you expose all fields including those which are not writable it may be required but at this stage I still fail why this is requested.
I think we don’t need to expose RES fields to users. I was thinking of case where a RES0 field is repurposed for something else, but that should be taken care by zeroing the ID regs array before initiating the named model hierarchy. (RES1 field in CTR_EL0 needs some handling).
On why we even need to expose non-writable fields:
- Assume some non-writable field mismatches for the model and host, why do we want to stop users from explicitly overriding the model's field value to host value?
Quoted 3 lines
Quoted 2 lines
- Emit a dummy 64-bit VAL field for registers with no defined fields, such as
AIDR_EL1andREVIDR_EL1.This is yet another functional change that could be separate.
Acked, will do in v4.
Quoted 117 lines
Thanks
Eric
Quoted 113 lines
Signed-off-by Khushit Shah <[email protected]>---
.../update-aarch64-cpu-sysreg-properties.py| 67 +++++++++++++------1 file changed, 45 insertions(+), 22 deletions(-)mode change 100644 => 100755
scripts/update-aarch64-cpu-sysreg-properties.pyscripts/update-aarch64-cpu-sysreg-properties.py +23
-0@@ -106,6 +106,29 @@ def collect_fields(item, bit_offset=0): return fields +def parse_value_int(raw_val): + if raw_val is None or isinstance(raw_val, bool): + return None + + # may already be real number + if isinstance(raw_val, int): + return raw_val + + raw_str = str(raw_val).strip() + + if "'" in raw_str: + # quoted bitstring like "'0100'" + bits = raw_str.replace("'", "") + try: + return int(bits, 2) + except ValueError: + return None + + # unquoted, try decimal + try: + return int(raw_str, 0) + except ValueError: + return Nonedef
extract_field_enums(field):enums = []scripts/update-aarch64-cpu-sysreg-properties.py +12
-21@@ -124,32 +147,23 @@ def extract_field_enums(field): if not isinstance(val_entries, list): return enums + # A Values.ValueRange field specifies start and end value for a range. + # Don't enumerate anything for them. + for val_entry in val_entries: + if isinstance(val_entry, dict) and \ + val_entry.get("_type") == "Values.ValueRange": + return [] + for val_entry in val_entries: if not isinstance(val_entry, dict): continue - + if val_entry.get("_type") == "Values.Value": - raw_val = val_entry.get("value") - if raw_val is None: + int_val = parse_value_int(val_entry.get("value")) + if int_val is None: continue - - # some of the values have ' like "'0100'" - raw_val_str = str(raw_val).strip().replace("'", "") - - try: - # convert into bin - int_val = int(raw_val_str, 2) - except ValueError: - try: - # Fallback to dec if not bin - int_val = int(raw_val_str, 0) - except ValueError: - continue - - enums.append({ - 'value': int_val - }) - + enums.append({'value': int_val}) + return enumsdef
generate_sysreg_properties_from_registers_json(id_reg_names, raw_json_path):scripts/update-aarch64-cpu-sysreg-properties.py +10
-1@@ -210,7 +224,7 @@ def generate_sysreg_properties_from_registers_json(id_reg_names, raw_json_path): msb > current_fieldset_fields[unique_key]['msb']: enums = extract_field_enums(val) current_fieldset_fields[unique_key] = { - 'raw_name': name, + 'raw_name': unique_key, 'lsb': lsb, 'msb': msb, 'width': width,@@ -238,6 +252,15 @@ def generate_sysreg_properties_from_registers_json(id_reg_names, raw_json_path): # Sort decreasing lsbs sorted_fields = sorted(unique_fields.items(), key=lambda x: x[1]['lsb'], reverse=True) + if len(sorted_fields) == 0: + # cases like REVIDR_EL1 and AIDR_EL1. + # augment a dummy fields VAL. + sorted_fields.append(('VAL', { + 'lsb': 0, + 'msb': 63, + 'width': 64, + 'enums': [] + })) for unique_key, bits in sorted_fields: enums_list = bits.get('enums', [])
Re: [RFC PATCH v3 02/19] scripts: bug fixes in update-aarch64-cpu-sysreg-properties
Quoted 18 lines · Khushit Shah
Quoted 10 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 5 lines
Quoted 2 lines · Khushit Shah
- handle quoted bitstrings and decimal
- skip Values.ValueRange entries.The above is the issue you reported on my v6. See my comment on the other thread.
Acked.
Quoted 2 lines
Quoted 2 lines
- Emit unique RESx_{lsb} names for reserved fields so no two fields in a register share a name.
Quoted 8 lines
Quoted 3 lines
The requirement for naming RES field needs to be explained. I understand that now you expose all fields including those which are not writable it may be required but at this stage I still fail why this is requested.
I think we don’t need to expose RES fields to users. I was thinking of case where a RES0 field is repurposed for something else, but that should be taken care by zeroing the ID regs array before initiating the named model hierarchy. (RES1 field in
CTR_EL0needs some handling).
I also think so. you can rely on AARCHMRS desc to identify the right default values.
Quoted 5 lines
On why we even need to expose non-writable fields:
- Assume some non-writable field mismatches for the model and host, why do we want to stop users from explicitly overriding the model's field value to host value?
I agree this needs to be checked. However as I suggested I think you can avoid exposing them to the end-users as props. You just need to read the value from host and compare it with the value set in the named model.
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
- Emit a dummy 64-bit VAL field for registers with no defined fields, such as
AIDR_EL1andREVIDR_EL1.This is yet another functional change that could be separate.
Acked, will do in v4.
Thanks
Eric
Quoted 116 lines
Quoted 116 lines
Thanks
Eric
Quoted 112 lines
Signed-off-by Khushit Shah <[email protected]>---
.../update-aarch64-cpu-sysreg-properties.py| 67 +++++++++++++------1 file changed, 45 insertions(+), 22 deletions(-)mode change 100644 => 100755
scripts/update-aarch64-cpu-sysreg-properties.pyscripts/update-aarch64-cpu-sysreg-properties.py +23
-0@@ -106,6 +106,29 @@ def collect_fields(item, bit_offset=0): return fields +def parse_value_int(raw_val): + if raw_val is None or isinstance(raw_val, bool): + return None + + # may already be real number + if isinstance(raw_val, int): + return raw_val + + raw_str = str(raw_val).strip() + + if "'" in raw_str: + # quoted bitstring like "'0100'" + bits = raw_str.replace("'", "") + try: + return int(bits, 2) + except ValueError: + return None + + # unquoted, try decimal + try: + return int(raw_str, 0) + except ValueError: + return Nonedef
extract_field_enums(field):enums = []scripts/update-aarch64-cpu-sysreg-properties.py +12
-21@@ -124,32 +147,23 @@ def extract_field_enums(field): if not isinstance(val_entries, list): return enums + # A Values.ValueRange field specifies start and end value for a range. + # Don't enumerate anything for them. + for val_entry in val_entries: + if isinstance(val_entry, dict) and \ + val_entry.get("_type") == "Values.ValueRange": + return [] + for val_entry in val_entries: if not isinstance(val_entry, dict): continue - + if val_entry.get("_type") == "Values.Value": - raw_val = val_entry.get("value") - if raw_val is None: + int_val = parse_value_int(val_entry.get("value")) + if int_val is None: continue - - # some of the values have ' like "'0100'" - raw_val_str = str(raw_val).strip().replace("'", "") - - try: - # convert into bin - int_val = int(raw_val_str, 2) - except ValueError: - try: - # Fallback to dec if not bin - int_val = int(raw_val_str, 0) - except ValueError: - continue - - enums.append({ - 'value': int_val - }) - + enums.append({'value': int_val}) + return enumsdef
generate_sysreg_properties_from_registers_json(id_reg_names, raw_json_path):scripts/update-aarch64-cpu-sysreg-properties.py +10
-1@@ -210,7 +224,7 @@ def generate_sysreg_properties_from_registers_json(id_reg_names, raw_json_path): msb > current_fieldset_fields[unique_key]['msb']: enums = extract_field_enums(val) current_fieldset_fields[unique_key] = { - 'raw_name': name, + 'raw_name': unique_key, 'lsb': lsb, 'msb': msb, 'width': width,@@ -238,6 +252,15 @@ def generate_sysreg_properties_from_registers_json(id_reg_names, raw_json_path): # Sort decreasing lsbs sorted_fields = sorted(unique_fields.items(), key=lambda x: x[1]['lsb'], reverse=True) + if len(sorted_fields) == 0: + # cases like REVIDR_EL1 and AIDR_EL1. + # augment a dummy fields VAL. + sorted_fields.append(('VAL', { + 'lsb': 0, + 'msb': 63, + 'width': 64, + 'enums': [] + })) for unique_key, bits in sorted_fields: enums_list = bits.get('enums', [])
Re: [RFC PATCH v3 02/19] scripts: bug fixes in update-aarch64-cpu-sysreg-properties
Quoted 33 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 21 lines · Khushit Shah
Quoted 10 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 5 lines
Quoted 2 lines · Khushit Shah
- handle quoted bitstrings and decimal
- skip Values.ValueRange entries.The above is the issue you reported on my v6. See my comment on the other thread.
Acked.
Quoted 5 lines
Quoted 2 lines
- Emit unique RESx_{lsb} names for reserved fields so no two fields in a register share a name.
The requirement for naming RES field needs to be explained. I understand that now you expose all fields including those which are not writable it may be required but at this stage I still fail why this is requested.
Quoted 7 lines
Quoted 5 lines
I think we don’t need to expose RES fields to users. I was thinking of case where a RES0 field is repurposed for something else, but that should be taken care by zeroing the ID regs array before initiating the named model hierarchy. (RES1 field in
CTR_EL0needs some handling).I also think so. you can rely on AARCHMRS desc to identify the right default values.
Acked.
Quoted 9 lines
Quoted 5 lines
On why we even need to expose non-writable fields:
- Assume some non-writable field mismatches for the model and host, why do we want to stop users from explicitly overriding the model's field value to host value?I agree this needs to be checked. However as I suggested I think you can avoid exposing them to the end-users as props. You just need to read the value from host and compare it with the value set in the named model.
I am not sure how that will work, assume following scenario:
- Host is running on neoverse-v2 core and we want to run guest with neoverse-v1 model. “pauth” fields are not exactly writable, and "neoverse-v1” implements different pauth algorithm than "neoverse-v2”. Now, if we don’t expose “pauth” as it is not writable, how will end user be able to say I want to run neoverse-v1 model so please disable "pauth”.
What I want to support is end user to say "please use the host value for some non-writable fields as the model I want to run has values which are not supported on the current host.”
The same “pauth” example will suffer if we don’t expose APA/GPA in cpu-model-expansion, how will management stack infer that both host supports “pauth" but they support different versions and are not compatible?
Warm Regards,
Khushit
Quoted 126 lines
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
- Emit a dummy 64-bit VAL field for registers with no defined fields, such as
AIDR_EL1andREVIDR_EL1.This is yet another functional change that could be separate.
Acked, will do in v4.
Thanks
Eric
Quoted 116 lines
Quoted 116 lines
Thanks
Eric
Quoted 112 lines
Signed-off-by Khushit Shah <[email protected]>---
.../update-aarch64-cpu-sysreg-properties.py| 67 +++++++++++++------1 file changed, 45 insertions(+), 22 deletions(-)mode change 100644 => 100755
scripts/update-aarch64-cpu-sysreg-properties.pyscripts/update-aarch64-cpu-sysreg-properties.py +23
-0@@ -106,6 +106,29 @@ def collect_fields(item, bit_offset=0): return fields +def parse_value_int(raw_val): + if raw_val is None or isinstance(raw_val, bool): + return None + + # may already be real number + if isinstance(raw_val, int): + return raw_val + + raw_str = str(raw_val).strip() + + if "'" in raw_str: + # quoted bitstring like "'0100'" + bits = raw_str.replace("'", "") + try: + return int(bits, 2) + except ValueError: + return None + + # unquoted, try decimal + try: + return int(raw_str, 0) + except ValueError: + return Nonedef
extract_field_enums(field):enums = []scripts/update-aarch64-cpu-sysreg-properties.py +12
-21@@ -124,32 +147,23 @@ def extract_field_enums(field): if not isinstance(val_entries, list): return enums + # A Values.ValueRange field specifies start and end value for a range. + # Don't enumerate anything for them. + for val_entry in val_entries: + if isinstance(val_entry, dict) and \ + val_entry.get("_type") == "Values.ValueRange": + return [] + for val_entry in val_entries: if not isinstance(val_entry, dict): continue - + if val_entry.get("_type") == "Values.Value": - raw_val = val_entry.get("value") - if raw_val is None: + int_val = parse_value_int(val_entry.get("value")) + if int_val is None: continue - - # some of the values have ' like "'0100'" - raw_val_str = str(raw_val).strip().replace("'", "") - - try: - # convert into bin - int_val = int(raw_val_str, 2) - except ValueError: - try: - # Fallback to dec if not bin - int_val = int(raw_val_str, 0) - except ValueError: - continue - - enums.append({ - 'value': int_val - }) - + enums.append({'value': int_val}) + return enumsdef
generate_sysreg_properties_from_registers_json(id_reg_names, raw_json_path):scripts/update-aarch64-cpu-sysreg-properties.py +10
-1@@ -210,7 +224,7 @@ def generate_sysreg_properties_from_registers_json(id_reg_names, raw_json_path): msb > current_fieldset_fields[unique_key]['msb']: enums = extract_field_enums(val) current_fieldset_fields[unique_key] = { - 'raw_name': name, + 'raw_name': unique_key, 'lsb': lsb, 'msb': msb, 'width': width,@@ -238,6 +252,15 @@ def generate_sysreg_properties_from_registers_json(id_reg_names, raw_json_path): # Sort decreasing lsbs sorted_fields = sorted(unique_fields.items(), key=lambda x: x[1]['lsb'], reverse=True) + if len(sorted_fields) == 0: + # cases like REVIDR_EL1 and AIDR_EL1. + # augment a dummy fields VAL. + sorted_fields.append(('VAL', { + 'lsb': 0, + 'msb': 63, + 'width': 64, + 'enums': [] + })) for unique_key, bits in sorted_fields: enums_list = bits.get('enums', [])
Re: [RFC PATCH v3 02/19] scripts: bug fixes in update-aarch64-cpu-sysreg-properties
Quoted 49 lines · Khushit Shah
Quoted 31 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 20 lines · Khushit Shah
Quoted 9 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 5 lines
Quoted 2 lines · Khushit Shah
- handle quoted bitstrings and decimal
- skip Values.ValueRange entries.The above is the issue you reported on my v6. See my comment on the other thread.
Acked.
Quoted 5 lines
Quoted 2 lines
- Emit unique RESx_{lsb} names for reserved fields so no two fields in a register share a name.
The requirement for naming RES field needs to be explained. I understand that now you expose all fields including those which are not writable it may be required but at this stage I still fail why this is requested.
Quoted 7 lines
Quoted 5 lines
I think we don’t need to expose RES fields to users. I was thinking of case where a RES0 field is repurposed for something else, but that should be taken care by zeroing the ID regs array before initiating the named model hierarchy. (RES1 field in
CTR_EL0needs some handling).I also think so. you can rely on AARCHMRS desc to identify the right default values.
Acked.
Quoted 7 lines
Quoted 4 lines
On why we even need to expose non-writable fields:
- Assume some non-writable field mismatches for the model and host, why do we want to stop users from explicitly overriding the model's field value to host value?I agree this needs to be checked. However as I suggested I think you can avoid exposing them to the end-users as props. You just need to read the value from host and compare it with the value set in the named model.
I am not sure how that will work, assume following scenario:
Quoted 8 lines
- Host is running on
neoverse-v2core and we want to run guest withneoverse-v1model. “pauth” fields are not exactly writable, and "neoverse-v1” implements different pauth algorithm than "neoverse-v2”. Now, if we don’t expose “pauth” as it is not writable, how will end user be able to say I want to run neoverse-v1 model so please disable "pauth”.What I want to support is end user to say "please use the host value for some non-writable fields as the model I want to run has values which are not supported on the current host.”
OK I see your point now. sorry for the misunderstanding. So in that case effectively you need a true QEMU prop for each field even for those which are not KVM writable. Please ignore my previous reply ;-)
Thanks
Eric
Quoted 132 lines
The same “pauth” example will suffer if we don’t expose APA/GPA in cpu-model-expansion, how will management stack infer that both host supports “pauth" but they support different versions and are not compatible?
Warm Regards,
KhushitQuoted 123 lines
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
- Emit a dummy 64-bit VAL field for registers with no defined fields, such as
AIDR_EL1andREVIDR_EL1.This is yet another functional change that could be separate.
Acked, will do in v4.
Thanks
Eric
Quoted 115 lines
Quoted 115 lines
Thanks
Eric
Quoted 112 lines
Signed-off-by Khushit Shah <[email protected]>---
.../update-aarch64-cpu-sysreg-properties.py| 67 +++++++++++++------1 file changed, 45 insertions(+), 22 deletions(-)mode change 100644 => 100755
scripts/update-aarch64-cpu-sysreg-properties.pyscripts/update-aarch64-cpu-sysreg-properties.py +23
-0@@ -106,6 +106,29 @@ def collect_fields(item, bit_offset=0): return fields +def parse_value_int(raw_val): + if raw_val is None or isinstance(raw_val, bool): + return None + + # may already be real number + if isinstance(raw_val, int): + return raw_val + + raw_str = str(raw_val).strip() + + if "'" in raw_str: + # quoted bitstring like "'0100'" + bits = raw_str.replace("'", "") + try: + return int(bits, 2) + except ValueError: + return None + + # unquoted, try decimal + try: + return int(raw_str, 0) + except ValueError: + return Nonedef
extract_field_enums(field):enums = []scripts/update-aarch64-cpu-sysreg-properties.py +12
-21@@ -124,32 +147,23 @@ def extract_field_enums(field): if not isinstance(val_entries, list): return enums + # A Values.ValueRange field specifies start and end value for a range. + # Don't enumerate anything for them. + for val_entry in val_entries: + if isinstance(val_entry, dict) and \ + val_entry.get("_type") == "Values.ValueRange": + return [] + for val_entry in val_entries: if not isinstance(val_entry, dict): continue - + if val_entry.get("_type") == "Values.Value": - raw_val = val_entry.get("value") - if raw_val is None: + int_val = parse_value_int(val_entry.get("value")) + if int_val is None: continue - - # some of the values have ' like "'0100'" - raw_val_str = str(raw_val).strip().replace("'", "") - - try: - # convert into bin - int_val = int(raw_val_str, 2) - except ValueError: - try: - # Fallback to dec if not bin - int_val = int(raw_val_str, 0) - except ValueError: - continue - - enums.append({ - 'value': int_val - }) - + enums.append({'value': int_val}) + return enumsdef
generate_sysreg_properties_from_registers_json(id_reg_names, raw_json_path):scripts/update-aarch64-cpu-sysreg-properties.py +10
-1@@ -210,7 +224,7 @@ def generate_sysreg_properties_from_registers_json(id_reg_names, raw_json_path): msb > current_fieldset_fields[unique_key]['msb']: enums = extract_field_enums(val) current_fieldset_fields[unique_key] = { - 'raw_name': name, + 'raw_name': unique_key, 'lsb': lsb, 'msb': msb, 'width': width,@@ -238,6 +252,15 @@ def generate_sysreg_properties_from_registers_json(id_reg_names, raw_json_path): # Sort decreasing lsbs sorted_fields = sorted(unique_fields.items(), key=lambda x: x[1]['lsb'], reverse=True) + if len(sorted_fields) == 0: + # cases like REVIDR_EL1 and AIDR_EL1. + # augment a dummy fields VAL. + sorted_fields.append(('VAL', { + 'lsb': 0, + 'msb': 63, + 'width': 64, + 'enums': [] + })) for unique_key, bits in sorted_fields: enums_list = bits.get('enums', [])
RFC PATCH v3 3/19 target/arm: regenerate cpu-idregs.h.inc
In reply to Khushit Shah--- target/arm/cpu-idregs.h.inc | 165 +++++++++++++++++------------------- 1 file changed, 76 insertions(+), 89 deletions(-)
target/arm/cpu-idregs.h.inc +76 -89
@@ -12,23 +12,24 @@ /* IDREG_END(REG) */ IDREG_START(AIDR_EL1) + IDREG_FIELD(AIDR_EL1, VAL, 0, 64) IDREG_END(AIDR_EL1) IDREG_START(CCSIDR2_EL1) - IDREG_FIELD(CCSIDR2_EL1, RES0, 24, 40) + IDREG_FIELD(CCSIDR2_EL1, RES0_24, 24, 40) IDREG_FIELD(CCSIDR2_EL1, NumSets, 0, 24) IDREG_END(CCSIDR2_EL1) IDREG_START(CCSIDR_EL1) - IDREG_FIELD(CCSIDR_EL1, RES0, 56, 8) + IDREG_FIELD(CCSIDR_EL1, RES0_56, 56, 8) IDREG_FIELD(CCSIDR_EL1, NumSets, 32, 24) - IDREG_FIELD(CCSIDR_EL1, RES0, 24, 8) + IDREG_FIELD(CCSIDR_EL1, RES0_24, 24, 8) IDREG_FIELD(CCSIDR_EL1, Associativity, 3, 21) IDREG_FIELD(CCSIDR_EL1, LineSize, 0, 3) IDREG_END(CCSIDR_EL1) IDREG_START(CLIDR_EL1) - IDREG_FIELD(CLIDR_EL1, RES0, 47, 17) + IDREG_FIELD(CLIDR_EL1, RES0_47, 47, 17) IDREG_FIELD(CLIDR_EL1, Ttype7, 45, 2) IDREG_FIELD(CLIDR_EL1, Ttype6, 43, 2) IDREG_FIELD(CLIDR_EL1, Ttype5, 41, 2)
@@ -59,10 +60,10 @@ IDREG_START(CLIDR_EL1) IDREG_END(CLIDR_EL1) IDREG_START(CTR_EL0) - IDREG_FIELD(CTR_EL0, RES0, 38, 26) + IDREG_FIELD(CTR_EL0, RES0_38, 38, 26) IDREG_FIELD(CTR_EL0, TminLine, 32, 6) - IDREG_FIELD(CTR_EL0, RES1, 31, 1) - IDREG_FIELD(CTR_EL0, RES0, 30, 1) + IDREG_FIELD(CTR_EL0, RES1_31, 31, 1) + IDREG_FIELD(CTR_EL0, RES0_30, 30, 1) IDREG_FIELD_START(CTR_EL0, DIC, 29, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -80,28 +81,28 @@ IDREG_START(CTR_EL0) IDREG_FIELD_ARCH_VAL(2) IDREG_FIELD_ARCH_VAL(3) IDREG_FIELD_END(CTR_EL0, L1Ip) - IDREG_FIELD(CTR_EL0, RES0, 4, 10) + IDREG_FIELD(CTR_EL0, RES0_4, 4, 10) IDREG_FIELD(CTR_EL0, IminLine, 0, 4) IDREG_END(CTR_EL0) IDREG_START(DCZID_EL0) - IDREG_FIELD(DCZID_EL0, RES0, 9, 55) + IDREG_FIELD(DCZID_EL0, RES0_9, 9, 55) IDREG_FIELD(DCZID_EL0, TBS, 5, 4) IDREG_FIELD(DCZID_EL0, DZP, 4, 1) IDREG_FIELD(DCZID_EL0, BS, 0, 4) IDREG_END(DCZID_EL0) IDREG_START(GMID_EL1) - IDREG_FIELD(GMID_EL1, RES0, 4, 60) + IDREG_FIELD(GMID_EL1, RES0_4, 4, 60) IDREG_FIELD(GMID_EL1, BS, 0, 4) IDREG_END(GMID_EL1) IDREG_START(ID_AA64AFR0_EL1) - IDREG_FIELD(ID_AA64AFR0_EL1, RES0, 32, 32) + IDREG_FIELD(ID_AA64AFR0_EL1, RES0_32, 32, 32) IDREG_END(ID_AA64AFR0_EL1) IDREG_START(ID_AA64AFR1_EL1) - IDREG_FIELD(ID_AA64AFR1_EL1, RES0, 0, 64) + IDREG_FIELD(ID_AA64AFR1_EL1, RES0_0, 0, 64) IDREG_END(ID_AA64AFR1_EL1) IDREG_START(ID_AA64DFR0_EL1)
@@ -145,18 +146,14 @@ IDREG_START(ID_AA64DFR0_EL1) IDREG_FIELD_ARCH_VAL(5) IDREG_FIELD_ARCH_VAL(6) IDREG_FIELD_END(ID_AA64DFR0_EL1, PMSVer) - IDREG_FIELD_START(ID_AA64DFR0_EL1, CTX_CMPs, 28, 4) - IDREG_FIELD_ARCH_VAL(15) - IDREG_FIELD_END(ID_AA64DFR0_EL1, CTX_CMPs) - IDREG_FIELD(ID_AA64DFR0_EL1, RES0, 24, 4) + IDREG_FIELD(ID_AA64DFR0_EL1, CTX_CMPs, 28, 4) + IDREG_FIELD(ID_AA64DFR0_EL1, RES0_24, 24, 4) IDREG_FIELD(ID_AA64DFR0_EL1, WRPs, 20, 4) IDREG_FIELD_START(ID_AA64DFR0_EL1, PMSS, 16, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64DFR0_EL1, PMSS) - IDREG_FIELD_START(ID_AA64DFR0_EL1, BRPs, 12, 4) - IDREG_FIELD_ARCH_VAL(15) - IDREG_FIELD_END(ID_AA64DFR0_EL1, BRPs) + IDREG_FIELD(ID_AA64DFR0_EL1, BRPs, 12, 4) IDREG_FIELD_START(ID_AA64DFR0_EL1, PMUVer, 8, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -209,20 +206,14 @@ IDREG_START(ID_AA64DFR1_EL1) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_ARCH_VAL(2) IDREG_FIELD_END(ID_AA64DFR1_EL1, SPMU) - IDREG_FIELD_START(ID_AA64DFR1_EL1, CTX_CMPs, 24, 8) - IDREG_FIELD_ARCH_VAL(0) - IDREG_FIELD_END(ID_AA64DFR1_EL1, CTX_CMPs) - IDREG_FIELD_START(ID_AA64DFR1_EL1, WRPs, 16, 8) - IDREG_FIELD_ARCH_VAL(0) - IDREG_FIELD_END(ID_AA64DFR1_EL1, WRPs) - IDREG_FIELD_START(ID_AA64DFR1_EL1, BRPs, 8, 8) - IDREG_FIELD_ARCH_VAL(0) - IDREG_FIELD_END(ID_AA64DFR1_EL1, BRPs) + IDREG_FIELD(ID_AA64DFR1_EL1, CTX_CMPs, 24, 8) + IDREG_FIELD(ID_AA64DFR1_EL1, WRPs, 16, 8) + IDREG_FIELD(ID_AA64DFR1_EL1, BRPs, 8, 8) IDREG_FIELD(ID_AA64DFR1_EL1, SYSPMUID, 0, 8) IDREG_END(ID_AA64DFR1_EL1) IDREG_START(ID_AA64DFR2_EL1) - IDREG_FIELD(ID_AA64DFR2_EL1, RES0, 28, 36) + IDREG_FIELD(ID_AA64DFR2_EL1, RES0_28, 28, 36) IDREG_FIELD_START(ID_AA64DFR2_EL1, TRBE_EXC, 24, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -235,7 +226,7 @@ IDREG_START(ID_AA64DFR2_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64DFR2_EL1, SPE_EXC) - IDREG_FIELD(ID_AA64DFR2_EL1, RES0, 8, 8) + IDREG_FIELD(ID_AA64DFR2_EL1, RES0_8, 8, 8) IDREG_FIELD_START(ID_AA64DFR2_EL1, BWE, 4, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -248,7 +239,7 @@ IDREG_START(ID_AA64DFR2_EL1) IDREG_END(ID_AA64DFR2_EL1) IDREG_START(ID_AA64FPFR0_EL1) - IDREG_FIELD(ID_AA64FPFR0_EL1, RES0, 32, 32) + IDREG_FIELD(ID_AA64FPFR0_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_AA64FPFR0_EL1, F8CVT, 31, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -273,13 +264,13 @@ IDREG_START(ID_AA64FPFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64FPFR0_EL1, F8MM4) - IDREG_FIELD(ID_AA64FPFR0_EL1, RES0, 16, 10) + IDREG_FIELD(ID_AA64FPFR0_EL1, RES0_16, 16, 10) IDREG_FIELD_START(ID_AA64FPFR0_EL1, F16MM2, 15, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64FPFR0_EL1, F16MM2) - IDREG_FIELD(ID_AA64FPFR0_EL1, RES0, 8, 7) - IDREG_FIELD(ID_AA64FPFR0_EL1, RAZ, 2, 6) + IDREG_FIELD(ID_AA64FPFR0_EL1, RES0_8, 8, 7) + IDREG_FIELD(ID_AA64FPFR0_EL1, RAZ_2, 2, 6) IDREG_FIELD_START(ID_AA64FPFR0_EL1, F8E4M3, 1, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -331,7 +322,7 @@ IDREG_START(ID_AA64ISAR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64ISAR0_EL1, RDM) - IDREG_FIELD(ID_AA64ISAR0_EL1, RES0, 24, 4) + IDREG_FIELD(ID_AA64ISAR0_EL1, RES0_24, 24, 4) IDREG_FIELD_START(ID_AA64ISAR0_EL1, Atomic, 20, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(2)
@@ -355,7 +346,7 @@ IDREG_START(ID_AA64ISAR0_EL1) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_ARCH_VAL(2) IDREG_FIELD_END(ID_AA64ISAR0_EL1, AES) - IDREG_FIELD(ID_AA64ISAR0_EL1, RES0, 0, 4) + IDREG_FIELD(ID_AA64ISAR0_EL1, RES0_0, 0, 4) IDREG_END(ID_AA64ISAR0_EL1) IDREG_START(ID_AA64ISAR1_EL1)
@@ -519,7 +510,7 @@ IDREG_START(ID_AA64ISAR2_EL1) IDREG_END(ID_AA64ISAR2_EL1) IDREG_START(ID_AA64ISAR3_EL1) - IDREG_FIELD(ID_AA64ISAR3_EL1, RES0, 48, 16) + IDREG_FIELD(ID_AA64ISAR3_EL1, RES0_48, 48, 16) IDREG_FIELD_START(ID_AA64ISAR3_EL1, LSCP, 44, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -583,7 +574,7 @@ IDREG_START(ID_AA64MMFR0_EL1) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_ARCH_VAL(2) IDREG_FIELD_END(ID_AA64MMFR0_EL1, FGT) - IDREG_FIELD(ID_AA64MMFR0_EL1, RES0, 48, 8) + IDREG_FIELD(ID_AA64MMFR0_EL1, RES0_48, 48, 8) IDREG_FIELD_START(ID_AA64MMFR0_EL1, ExS, 44, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -736,7 +727,7 @@ IDREG_START(ID_AA64MMFR2_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64MMFR2_EL1, TTL) - IDREG_FIELD(ID_AA64MMFR2_EL1, RES0, 44, 4) + IDREG_FIELD(ID_AA64MMFR2_EL1, RES0_44, 44, 4) IDREG_FIELD_START(ID_AA64MMFR2_EL1, FWB, 40, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -802,7 +793,7 @@ IDREG_START(ID_AA64MMFR3_EL1) IDREG_FIELD_ARCH_VAL(2) IDREG_FIELD_ARCH_VAL(3) IDREG_FIELD_END(ID_AA64MMFR3_EL1, SDERR) - IDREG_FIELD(ID_AA64MMFR3_EL1, RES0, 48, 4) + IDREG_FIELD(ID_AA64MMFR3_EL1, RES0_48, 48, 4) IDREG_FIELD_START(ID_AA64MMFR3_EL1, ANERR, 44, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1056,7 +1047,7 @@ IDREG_START(ID_AA64PFR1_EL1) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_ARCH_VAL(2) IDREG_FIELD_END(ID_AA64PFR1_EL1, SME) - IDREG_FIELD(ID_AA64PFR1_EL1, RES0, 20, 4) + IDREG_FIELD(ID_AA64PFR1_EL1, RES0_20, 20, 4) IDREG_FIELD_START(ID_AA64PFR1_EL1, MPAM_frac, 16, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1084,7 +1075,7 @@ IDREG_START(ID_AA64PFR1_EL1) IDREG_END(ID_AA64PFR1_EL1) IDREG_START(ID_AA64PFR2_EL1) - IDREG_FIELD(ID_AA64PFR2_EL1, RES0, 48, 16) + IDREG_FIELD(ID_AA64PFR2_EL1, RES0_48, 48, 16) IDREG_FIELD_START(ID_AA64PFR2_EL1, VMTETCL, 44, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1144,7 +1135,7 @@ IDREG_START(ID_AA64SMFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64SMFR0_EL1, FA64) - IDREG_FIELD(ID_AA64SMFR0_EL1, RES0, 62, 1) + IDREG_FIELD(ID_AA64SMFR0_EL1, RES0_62, 62, 1) IDREG_FIELD_START(ID_AA64SMFR0_EL1, LUT6, 61, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1164,7 +1155,7 @@ IDREG_START(ID_AA64SMFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(15) IDREG_FIELD_END(ID_AA64SMFR0_EL1, I16I64) - IDREG_FIELD(ID_AA64SMFR0_EL1, RES0, 49, 3) + IDREG_FIELD(ID_AA64SMFR0_EL1, RES0_49, 49, 3) IDREG_FIELD_START(ID_AA64SMFR0_EL1, F64F64, 48, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1209,7 +1200,7 @@ IDREG_START(ID_AA64SMFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64SMFR0_EL1, F32F32) - IDREG_FIELD(ID_AA64SMFR0_EL1, RES0, 31, 1) + IDREG_FIELD(ID_AA64SMFR0_EL1, RES0_31, 31, 1) IDREG_FIELD_START(ID_AA64SMFR0_EL1, SF8FMA, 30, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1222,7 +1213,7 @@ IDREG_START(ID_AA64SMFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64SMFR0_EL1, SF8DP2) - IDREG_FIELD(ID_AA64SMFR0_EL1, RES0, 26, 2) + IDREG_FIELD(ID_AA64SMFR0_EL1, RES0_26, 26, 2) IDREG_FIELD_START(ID_AA64SMFR0_EL1, SBitPerm, 25, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1235,12 +1226,12 @@ IDREG_START(ID_AA64SMFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64SMFR0_EL1, SFEXPA) - IDREG_FIELD(ID_AA64SMFR0_EL1, RES0, 17, 6) + IDREG_FIELD(ID_AA64SMFR0_EL1, RES0_17, 17, 6) IDREG_FIELD_START(ID_AA64SMFR0_EL1, STMOP, 16, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64SMFR0_EL1, STMOP) - IDREG_FIELD(ID_AA64SMFR0_EL1, RES0, 1, 15) + IDREG_FIELD(ID_AA64SMFR0_EL1, RES0_1, 1, 15) IDREG_FIELD_START(ID_AA64SMFR0_EL1, SMOP4, 0, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1248,7 +1239,7 @@ IDREG_START(ID_AA64SMFR0_EL1) IDREG_END(ID_AA64SMFR0_EL1) IDREG_START(ID_AA64ZFR0_EL1) - IDREG_FIELD(ID_AA64ZFR0_EL1, RES0, 60, 4) + IDREG_FIELD(ID_AA64ZFR0_EL1, RES0_60, 60, 4) IDREG_FIELD_START(ID_AA64ZFR0_EL1, F64MM, 56, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1269,12 +1260,12 @@ IDREG_START(ID_AA64ZFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64ZFR0_EL1, SM4) - IDREG_FIELD(ID_AA64ZFR0_EL1, RES0, 36, 4) + IDREG_FIELD(ID_AA64ZFR0_EL1, RES0_36, 36, 4) IDREG_FIELD_START(ID_AA64ZFR0_EL1, SHA3, 32, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64ZFR0_EL1, SHA3) - IDREG_FIELD(ID_AA64ZFR0_EL1, RES0, 28, 4) + IDREG_FIELD(ID_AA64ZFR0_EL1, RES0_28, 28, 4) IDREG_FIELD_START(ID_AA64ZFR0_EL1, B16B16, 24, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1294,7 +1285,7 @@ IDREG_START(ID_AA64ZFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64ZFR0_EL1, EltPerm) - IDREG_FIELD(ID_AA64ZFR0_EL1, RES0, 8, 4) + IDREG_FIELD(ID_AA64ZFR0_EL1, RES0_8, 8, 4) IDREG_FIELD_START(ID_AA64ZFR0_EL1, AES, 4, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1311,11 +1302,11 @@ IDREG_START(ID_AA64ZFR0_EL1) IDREG_END(ID_AA64ZFR0_EL1) IDREG_START(ID_AFR0_EL1) - IDREG_FIELD(ID_AFR0_EL1, RES0, 0, 64) + IDREG_FIELD(ID_AFR0_EL1, RES0_0, 0, 64) IDREG_END(ID_AFR0_EL1) IDREG_START(ID_DFR0_EL1) - IDREG_FIELD(ID_DFR0_EL1, RES0, 32, 32) + IDREG_FIELD(ID_DFR0_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_DFR0_EL1, TraceFilt, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1367,7 +1358,7 @@ IDREG_START(ID_DFR0_EL1) IDREG_END(ID_DFR0_EL1) IDREG_START(ID_DFR1_EL1) - IDREG_FIELD(ID_DFR1_EL1, RES0, 8, 56) + IDREG_FIELD(ID_DFR1_EL1, RES0_8, 8, 56) IDREG_FIELD_START(ID_DFR1_EL1, HPMN0, 4, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1380,7 +1371,7 @@ IDREG_START(ID_DFR1_EL1) IDREG_END(ID_DFR1_EL1) IDREG_START(ID_ISAR0_EL1) - IDREG_FIELD(ID_ISAR0_EL1, RES0, 28, 36) + IDREG_FIELD(ID_ISAR0_EL1, RES0_28, 28, 36) IDREG_FIELD_START(ID_ISAR0_EL1, Divide, 24, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1416,7 +1407,7 @@ IDREG_START(ID_ISAR0_EL1) IDREG_END(ID_ISAR0_EL1) IDREG_START(ID_ISAR1_EL1) - IDREG_FIELD(ID_ISAR1_EL1, RES0, 32, 32) + IDREG_FIELD(ID_ISAR1_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_ISAR1_EL1, Jazelle, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1455,7 +1446,7 @@ IDREG_START(ID_ISAR1_EL1) IDREG_END(ID_ISAR1_EL1) IDREG_START(ID_ISAR2_EL1) - IDREG_FIELD(ID_ISAR2_EL1, RES0, 32, 32) + IDREG_FIELD(ID_ISAR2_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_ISAR2_EL1, Reversal, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1501,7 +1492,7 @@ IDREG_START(ID_ISAR2_EL1) IDREG_END(ID_ISAR2_EL1) IDREG_START(ID_ISAR3_EL1) - IDREG_FIELD(ID_ISAR3_EL1, RES0, 32, 32) + IDREG_FIELD(ID_ISAR3_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_ISAR3_EL1, T32EE, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1539,7 +1530,7 @@ IDREG_START(ID_ISAR3_EL1) IDREG_END(ID_ISAR3_EL1) IDREG_START(ID_ISAR4_EL1) - IDREG_FIELD(ID_ISAR4_EL1, RES0, 32, 32) + IDREG_FIELD(ID_ISAR4_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_ISAR4_EL1, SWP_frac, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1564,12 +1555,12 @@ IDREG_START(ID_ISAR4_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_ISAR4_EL1, Writeback) - IDREG_FIELD_START(ID_ISAR4_EL1, WI, 4, 4) + IDREG_FIELD_START(ID_ISAR4_EL1, WI_4, 4, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_ARCH_VAL(3) IDREG_FIELD_ARCH_VAL(4) - IDREG_FIELD_END(ID_ISAR4_EL1, WI) + IDREG_FIELD_END(ID_ISAR4_EL1, WI_4) IDREG_FIELD_START(ID_ISAR4_EL1, Unpriv, 0, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1578,7 +1569,7 @@ IDREG_START(ID_ISAR4_EL1) IDREG_END(ID_ISAR4_EL1) IDREG_START(ID_ISAR5_EL1) - IDREG_FIELD(ID_ISAR5_EL1, RES0, 32, 32) + IDREG_FIELD(ID_ISAR5_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_ISAR5_EL1, VCMA, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1587,7 +1578,7 @@ IDREG_START(ID_ISAR5_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_ISAR5_EL1, RDM) - IDREG_FIELD(ID_ISAR5_EL1, RES0, 20, 4) + IDREG_FIELD(ID_ISAR5_EL1, RES0_20, 20, 4) IDREG_FIELD_START(ID_ISAR5_EL1, CRC32, 16, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1612,7 +1603,7 @@ IDREG_START(ID_ISAR5_EL1) IDREG_END(ID_ISAR5_EL1) IDREG_START(ID_ISAR6_EL1) - IDREG_FIELD(ID_ISAR6_EL1, RES0, 32, 32) + IDREG_FIELD(ID_ISAR6_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_ISAR6_EL1, CLRBHB, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1649,7 +1640,7 @@ IDREG_START(ID_ISAR6_EL1) IDREG_END(ID_ISAR6_EL1) IDREG_START(ID_MMFR0_EL1) - IDREG_FIELD(ID_MMFR0_EL1, RES0, 32, 32) + IDREG_FIELD(ID_MMFR0_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_MMFR0_EL1, InnerShr, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1696,7 +1687,7 @@ IDREG_START(ID_MMFR0_EL1) IDREG_END(ID_MMFR0_EL1) IDREG_START(ID_MMFR1_EL1) - IDREG_FIELD(ID_MMFR1_EL1, RES0, 32, 32) + IDREG_FIELD(ID_MMFR1_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_MMFR1_EL1, BPred, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1745,7 +1736,7 @@ IDREG_START(ID_MMFR1_EL1) IDREG_END(ID_MMFR1_EL1) IDREG_START(ID_MMFR2_EL1) - IDREG_FIELD(ID_MMFR2_EL1, RES0, 32, 32) + IDREG_FIELD(ID_MMFR2_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_MMFR2_EL1, HWAccFlg, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1784,7 +1775,7 @@ IDREG_START(ID_MMFR2_EL1) IDREG_END(ID_MMFR2_EL1) IDREG_START(ID_MMFR3_EL1) - IDREG_FIELD(ID_MMFR3_EL1, RES0, 32, 32) + IDREG_FIELD(ID_MMFR3_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_MMFR3_EL1, Supersec, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(15)
@@ -1824,7 +1815,7 @@ IDREG_START(ID_MMFR3_EL1) IDREG_END(ID_MMFR3_EL1) IDREG_START(ID_MMFR4_EL1) - IDREG_FIELD(ID_MMFR4_EL1, RES0, 32, 32) + IDREG_FIELD(ID_MMFR4_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_MMFR4_EL1, EVT, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1862,7 +1853,7 @@ IDREG_START(ID_MMFR4_EL1) IDREG_END(ID_MMFR4_EL1) IDREG_START(ID_MMFR5_EL1) - IDREG_FIELD(ID_MMFR5_EL1, RES0, 8, 56) + IDREG_FIELD(ID_MMFR5_EL1, RES0_8, 8, 56) IDREG_FIELD_START(ID_MMFR5_EL1, nTLBPA, 4, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1876,7 +1867,7 @@ IDREG_START(ID_MMFR5_EL1) IDREG_END(ID_MMFR5_EL1) IDREG_START(ID_PFR0_EL1) - IDREG_FIELD(ID_PFR0_EL1, RES0, 32, 32) + IDREG_FIELD(ID_PFR0_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_PFR0_EL1, RAS, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1918,7 +1909,7 @@ IDREG_START(ID_PFR0_EL1) IDREG_END(ID_PFR0_EL1) IDREG_START(ID_PFR1_EL1) - IDREG_FIELD(ID_PFR1_EL1, RES0, 32, 32) + IDREG_FIELD(ID_PFR1_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_PFR1_EL1, GIC, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -1958,7 +1949,7 @@ IDREG_START(ID_PFR1_EL1) IDREG_END(ID_PFR1_EL1) IDREG_START(ID_PFR2_EL1) - IDREG_FIELD(ID_PFR2_EL1, RES0, 12, 52) + IDREG_FIELD(ID_PFR2_EL1, RES0_12, 12, 52) IDREG_FIELD_START(ID_PFR2_EL1, RAS_frac, 8, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -2006,14 +1997,14 @@ IDREG_START(MIDR_EL1) IDREG_END(MIDR_EL1) IDREG_START(MPIDR_EL1) - IDREG_FIELD(MPIDR_EL1, RES0, 40, 24) + IDREG_FIELD(MPIDR_EL1, RES0_40, 40, 24) IDREG_FIELD(MPIDR_EL1, Aff3, 32, 8) - IDREG_FIELD(MPIDR_EL1, RES1, 31, 1) + IDREG_FIELD(MPIDR_EL1, RES1_31, 31, 1) IDREG_FIELD_START(MPIDR_EL1, U, 30, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(MPIDR_EL1, U) - IDREG_FIELD(MPIDR_EL1, RES0, 25, 5) + IDREG_FIELD(MPIDR_EL1, RES0_25, 25, 5) IDREG_FIELD_START(MPIDR_EL1, MT, 24, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -2024,7 +2015,7 @@ IDREG_START(MPIDR_EL1) IDREG_END(MPIDR_EL1) IDREG_START(MVFR0_EL1) - IDREG_FIELD(MVFR0_EL1, RES0, 32, 32) + IDREG_FIELD(MVFR0_EL1, RES0_32, 32, 32) IDREG_FIELD_START(MVFR0_EL1, FPRound, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -2063,7 +2054,7 @@ IDREG_START(MVFR0_EL1) IDREG_END(MVFR0_EL1) IDREG_START(MVFR1_EL1) - IDREG_FIELD(MVFR1_EL1, RES0, 32, 32) + IDREG_FIELD(MVFR1_EL1, RES0_32, 32, 32) IDREG_FIELD_START(MVFR1_EL1, SIMDFMAC, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -2102,7 +2093,7 @@ IDREG_START(MVFR1_EL1) IDREG_END(MVFR1_EL1) IDREG_START(MVFR2_EL1) - IDREG_FIELD(MVFR2_EL1, RES0, 8, 56) + IDREG_FIELD(MVFR2_EL1, RES0_8, 8, 56) IDREG_FIELD_START(MVFR2_EL1, FPMisc, 4, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)
@@ -2119,17 +2110,13 @@ IDREG_START(MVFR2_EL1) IDREG_END(MVFR2_EL1) IDREG_START(REVIDR_EL1) + IDREG_FIELD(REVIDR_EL1, VAL, 0, 64) IDREG_END(REVIDR_EL1) IDREG_START(SMIDR_EL1) - IDREG_FIELD(SMIDR_EL1, RES0, 60, 4) - IDREG_FIELD_START(SMIDR_EL1, NSMC, 56, 4) - IDREG_FIELD_ARCH_VAL(0) - IDREG_FIELD_ARCH_VAL(15) - IDREG_FIELD_END(SMIDR_EL1, NSMC) - IDREG_FIELD_START(SMIDR_EL1, HIP, 52, 4) - IDREG_FIELD_ARCH_VAL(0) - IDREG_FIELD_END(SMIDR_EL1, HIP) + IDREG_FIELD(SMIDR_EL1, RES0_60, 60, 4) + IDREG_FIELD(SMIDR_EL1, NSMC, 56, 4) + IDREG_FIELD(SMIDR_EL1, HIP, 52, 4) IDREG_FIELD(SMIDR_EL1, Affinity2, 32, 20) IDREG_FIELD_START(SMIDR_EL1, Implementer, 24, 8) IDREG_FIELD_ARCH_VAL(0)
@@ -2158,7 +2145,7 @@ IDREG_START(SMIDR_EL1) IDREG_FIELD_ARCH_VAL(2) IDREG_FIELD_ARCH_VAL(3) IDREG_FIELD_END(SMIDR_EL1, SH) - IDREG_FIELD(SMIDR_EL1, RES0, 12, 1) + IDREG_FIELD(SMIDR_EL1, RES0_12, 12, 1) IDREG_FIELD(SMIDR_EL1, Affinity, 0, 12) IDREG_END(SMIDR_EL1)
Signature · 1 line
2.52.0
Re: [RFC PATCH v3 03/19] target/arm: regenerate cpu-idregs.h.inc
Quoted 87 lines · Khushit Shah
Signed-off-by Khushit Shah <[email protected]>--- target/arm/cpu-idregs.h.inc | 165 +++++++++++++++++------------------- 1 file changed, 76 insertions(+), 89 deletions(-)target/arm/cpu-idregs.h.inc +13
-12@@ -12,23 +12,24 @@ /* IDREG_END(REG) */ IDREG_START(AIDR_EL1) + IDREG_FIELD(AIDR_EL1, VAL, 0, 64) IDREG_END(AIDR_EL1) IDREG_START(CCSIDR2_EL1) - IDREG_FIELD(CCSIDR2_EL1, RES0, 24, 40) + IDREG_FIELD(CCSIDR2_EL1, RES0_24, 24, 40) IDREG_FIELD(CCSIDR2_EL1, NumSets, 0, 24) IDREG_END(CCSIDR2_EL1) IDREG_START(CCSIDR_EL1) - IDREG_FIELD(CCSIDR_EL1, RES0, 56, 8) + IDREG_FIELD(CCSIDR_EL1, RES0_56, 56, 8) IDREG_FIELD(CCSIDR_EL1, NumSets, 32, 24) - IDREG_FIELD(CCSIDR_EL1, RES0, 24, 8) + IDREG_FIELD(CCSIDR_EL1, RES0_24, 24, 8) IDREG_FIELD(CCSIDR_EL1, Associativity, 3, 21) IDREG_FIELD(CCSIDR_EL1, LineSize, 0, 3) IDREG_END(CCSIDR_EL1) IDREG_START(CLIDR_EL1) - IDREG_FIELD(CLIDR_EL1, RES0, 47, 17) + IDREG_FIELD(CLIDR_EL1, RES0_47, 47, 17) IDREG_FIELD(CLIDR_EL1, Ttype7, 45, 2) IDREG_FIELD(CLIDR_EL1, Ttype6, 43, 2) IDREG_FIELD(CLIDR_EL1, Ttype5, 41, 2)@@ -59,10 +60,10 @@ IDREG_START(CLIDR_EL1) IDREG_END(CLIDR_EL1) IDREG_START(CTR_EL0) - IDREG_FIELD(CTR_EL0, RES0, 38, 26) + IDREG_FIELD(CTR_EL0, RES0_38, 38, 26) IDREG_FIELD(CTR_EL0, TminLine, 32, 6) - IDREG_FIELD(CTR_EL0, RES1, 31, 1) - IDREG_FIELD(CTR_EL0, RES0, 30, 1) + IDREG_FIELD(CTR_EL0, RES1_31, 31, 1) + IDREG_FIELD(CTR_EL0, RES0_30, 30, 1) IDREG_FIELD_START(CTR_EL0, DIC, 29, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -80,28 +81,28 @@ IDREG_START(CTR_EL0) IDREG_FIELD_ARCH_VAL(2) IDREG_FIELD_ARCH_VAL(3) IDREG_FIELD_END(CTR_EL0, L1Ip) - IDREG_FIELD(CTR_EL0, RES0, 4, 10) + IDREG_FIELD(CTR_EL0, RES0_4, 4, 10) IDREG_FIELD(CTR_EL0, IminLine, 0, 4) IDREG_END(CTR_EL0) IDREG_START(DCZID_EL0) - IDREG_FIELD(DCZID_EL0, RES0, 9, 55) + IDREG_FIELD(DCZID_EL0, RES0_9, 9, 55) IDREG_FIELD(DCZID_EL0, TBS, 5, 4) IDREG_FIELD(DCZID_EL0, DZP, 4, 1) IDREG_FIELD(DCZID_EL0, BS, 0, 4) IDREG_END(DCZID_EL0) IDREG_START(GMID_EL1) - IDREG_FIELD(GMID_EL1, RES0, 4, 60) + IDREG_FIELD(GMID_EL1, RES0_4, 4, 60) IDREG_FIELD(GMID_EL1, BS, 0, 4) IDREG_END(GMID_EL1) IDREG_START(ID_AA64AFR0_EL1) - IDREG_FIELD(ID_AA64AFR0_EL1, RES0, 32, 32) + IDREG_FIELD(ID_AA64AFR0_EL1, RES0_32, 32, 32) IDREG_END(ID_AA64AFR0_EL1) IDREG_START(ID_AA64AFR1_EL1) - IDREG_FIELD(ID_AA64AFR1_EL1, RES0, 0, 64) + IDREG_FIELD(ID_AA64AFR1_EL1, RES0_0, 0, 64) IDREG_END(ID_AA64AFR1_EL1) IDREG_START(ID_AA64DFR0_EL1)
target/arm/cpu-idregs.h.inc IDREG_START(ID_AA64DFR0_EL1) · line 149
Quoted 8 lines
target/arm/cpu-idregs.h.inc +1
-4@@ -145,18 +146,14 @@ IDREG_START(ID_AA64DFR0_EL1) IDREG_FIELD_ARCH_VAL(5) IDREG_FIELD_ARCH_VAL(6) IDREG_FIELD_END(ID_AA64DFR0_EL1, PMSVer) - IDREG_FIELD_START(ID_AA64DFR0_EL1, CTX_CMPs, 28, 4) - IDREG_FIELD_ARCH_VAL(15) - IDREG_FIELD_END(ID_AA64DFR0_EL1, CTX_CMPs) - IDREG_FIELD(ID_AA64DFR0_EL1, RES0, 24, 4) + IDREG_FIELD(ID_AA64DFR0_EL1, CTX_CMPs, 28, 4)
so it seems you remove all the ARCH values found in ValueRange (by the way there were incomplete)
Eric
Quoted 474 lines
target/arm/cpu-idregs.h.inc +58
-65+ IDREG_FIELD(ID_AA64DFR0_EL1, RES0_24, 24, 4) IDREG_FIELD(ID_AA64DFR0_EL1, WRPs, 20, 4) IDREG_FIELD_START(ID_AA64DFR0_EL1, PMSS, 16, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64DFR0_EL1, PMSS) - IDREG_FIELD_START(ID_AA64DFR0_EL1, BRPs, 12, 4) - IDREG_FIELD_ARCH_VAL(15) - IDREG_FIELD_END(ID_AA64DFR0_EL1, BRPs) + IDREG_FIELD(ID_AA64DFR0_EL1, BRPs, 12, 4) IDREG_FIELD_START(ID_AA64DFR0_EL1, PMUVer, 8, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -209,20 +206,14 @@ IDREG_START(ID_AA64DFR1_EL1) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_ARCH_VAL(2) IDREG_FIELD_END(ID_AA64DFR1_EL1, SPMU) - IDREG_FIELD_START(ID_AA64DFR1_EL1, CTX_CMPs, 24, 8) - IDREG_FIELD_ARCH_VAL(0) - IDREG_FIELD_END(ID_AA64DFR1_EL1, CTX_CMPs) - IDREG_FIELD_START(ID_AA64DFR1_EL1, WRPs, 16, 8) - IDREG_FIELD_ARCH_VAL(0) - IDREG_FIELD_END(ID_AA64DFR1_EL1, WRPs) - IDREG_FIELD_START(ID_AA64DFR1_EL1, BRPs, 8, 8) - IDREG_FIELD_ARCH_VAL(0) - IDREG_FIELD_END(ID_AA64DFR1_EL1, BRPs) + IDREG_FIELD(ID_AA64DFR1_EL1, CTX_CMPs, 24, 8) + IDREG_FIELD(ID_AA64DFR1_EL1, WRPs, 16, 8) + IDREG_FIELD(ID_AA64DFR1_EL1, BRPs, 8, 8) IDREG_FIELD(ID_AA64DFR1_EL1, SYSPMUID, 0, 8) IDREG_END(ID_AA64DFR1_EL1) IDREG_START(ID_AA64DFR2_EL1) - IDREG_FIELD(ID_AA64DFR2_EL1, RES0, 28, 36) + IDREG_FIELD(ID_AA64DFR2_EL1, RES0_28, 28, 36) IDREG_FIELD_START(ID_AA64DFR2_EL1, TRBE_EXC, 24, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -235,7 +226,7 @@ IDREG_START(ID_AA64DFR2_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64DFR2_EL1, SPE_EXC) - IDREG_FIELD(ID_AA64DFR2_EL1, RES0, 8, 8) + IDREG_FIELD(ID_AA64DFR2_EL1, RES0_8, 8, 8) IDREG_FIELD_START(ID_AA64DFR2_EL1, BWE, 4, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -248,7 +239,7 @@ IDREG_START(ID_AA64DFR2_EL1) IDREG_END(ID_AA64DFR2_EL1) IDREG_START(ID_AA64FPFR0_EL1) - IDREG_FIELD(ID_AA64FPFR0_EL1, RES0, 32, 32) + IDREG_FIELD(ID_AA64FPFR0_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_AA64FPFR0_EL1, F8CVT, 31, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -273,13 +264,13 @@ IDREG_START(ID_AA64FPFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64FPFR0_EL1, F8MM4) - IDREG_FIELD(ID_AA64FPFR0_EL1, RES0, 16, 10) + IDREG_FIELD(ID_AA64FPFR0_EL1, RES0_16, 16, 10) IDREG_FIELD_START(ID_AA64FPFR0_EL1, F16MM2, 15, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64FPFR0_EL1, F16MM2) - IDREG_FIELD(ID_AA64FPFR0_EL1, RES0, 8, 7) - IDREG_FIELD(ID_AA64FPFR0_EL1, RAZ, 2, 6) + IDREG_FIELD(ID_AA64FPFR0_EL1, RES0_8, 8, 7) + IDREG_FIELD(ID_AA64FPFR0_EL1, RAZ_2, 2, 6) IDREG_FIELD_START(ID_AA64FPFR0_EL1, F8E4M3, 1, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -331,7 +322,7 @@ IDREG_START(ID_AA64ISAR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64ISAR0_EL1, RDM) - IDREG_FIELD(ID_AA64ISAR0_EL1, RES0, 24, 4) + IDREG_FIELD(ID_AA64ISAR0_EL1, RES0_24, 24, 4) IDREG_FIELD_START(ID_AA64ISAR0_EL1, Atomic, 20, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(2)@@ -355,7 +346,7 @@ IDREG_START(ID_AA64ISAR0_EL1) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_ARCH_VAL(2) IDREG_FIELD_END(ID_AA64ISAR0_EL1, AES) - IDREG_FIELD(ID_AA64ISAR0_EL1, RES0, 0, 4) + IDREG_FIELD(ID_AA64ISAR0_EL1, RES0_0, 0, 4) IDREG_END(ID_AA64ISAR0_EL1) IDREG_START(ID_AA64ISAR1_EL1)@@ -519,7 +510,7 @@ IDREG_START(ID_AA64ISAR2_EL1) IDREG_END(ID_AA64ISAR2_EL1) IDREG_START(ID_AA64ISAR3_EL1) - IDREG_FIELD(ID_AA64ISAR3_EL1, RES0, 48, 16) + IDREG_FIELD(ID_AA64ISAR3_EL1, RES0_48, 48, 16) IDREG_FIELD_START(ID_AA64ISAR3_EL1, LSCP, 44, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -583,7 +574,7 @@ IDREG_START(ID_AA64MMFR0_EL1) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_ARCH_VAL(2) IDREG_FIELD_END(ID_AA64MMFR0_EL1, FGT) - IDREG_FIELD(ID_AA64MMFR0_EL1, RES0, 48, 8) + IDREG_FIELD(ID_AA64MMFR0_EL1, RES0_48, 48, 8) IDREG_FIELD_START(ID_AA64MMFR0_EL1, ExS, 44, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -736,7 +727,7 @@ IDREG_START(ID_AA64MMFR2_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64MMFR2_EL1, TTL) - IDREG_FIELD(ID_AA64MMFR2_EL1, RES0, 44, 4) + IDREG_FIELD(ID_AA64MMFR2_EL1, RES0_44, 44, 4) IDREG_FIELD_START(ID_AA64MMFR2_EL1, FWB, 40, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -802,7 +793,7 @@ IDREG_START(ID_AA64MMFR3_EL1) IDREG_FIELD_ARCH_VAL(2) IDREG_FIELD_ARCH_VAL(3) IDREG_FIELD_END(ID_AA64MMFR3_EL1, SDERR) - IDREG_FIELD(ID_AA64MMFR3_EL1, RES0, 48, 4) + IDREG_FIELD(ID_AA64MMFR3_EL1, RES0_48, 48, 4) IDREG_FIELD_START(ID_AA64MMFR3_EL1, ANERR, 44, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1056,7 +1047,7 @@ IDREG_START(ID_AA64PFR1_EL1) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_ARCH_VAL(2) IDREG_FIELD_END(ID_AA64PFR1_EL1, SME) - IDREG_FIELD(ID_AA64PFR1_EL1, RES0, 20, 4) + IDREG_FIELD(ID_AA64PFR1_EL1, RES0_20, 20, 4) IDREG_FIELD_START(ID_AA64PFR1_EL1, MPAM_frac, 16, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1084,7 +1075,7 @@ IDREG_START(ID_AA64PFR1_EL1) IDREG_END(ID_AA64PFR1_EL1) IDREG_START(ID_AA64PFR2_EL1) - IDREG_FIELD(ID_AA64PFR2_EL1, RES0, 48, 16) + IDREG_FIELD(ID_AA64PFR2_EL1, RES0_48, 48, 16) IDREG_FIELD_START(ID_AA64PFR2_EL1, VMTETCL, 44, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1144,7 +1135,7 @@ IDREG_START(ID_AA64SMFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64SMFR0_EL1, FA64) - IDREG_FIELD(ID_AA64SMFR0_EL1, RES0, 62, 1) + IDREG_FIELD(ID_AA64SMFR0_EL1, RES0_62, 62, 1) IDREG_FIELD_START(ID_AA64SMFR0_EL1, LUT6, 61, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1164,7 +1155,7 @@ IDREG_START(ID_AA64SMFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(15) IDREG_FIELD_END(ID_AA64SMFR0_EL1, I16I64) - IDREG_FIELD(ID_AA64SMFR0_EL1, RES0, 49, 3) + IDREG_FIELD(ID_AA64SMFR0_EL1, RES0_49, 49, 3) IDREG_FIELD_START(ID_AA64SMFR0_EL1, F64F64, 48, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1209,7 +1200,7 @@ IDREG_START(ID_AA64SMFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64SMFR0_EL1, F32F32) - IDREG_FIELD(ID_AA64SMFR0_EL1, RES0, 31, 1) + IDREG_FIELD(ID_AA64SMFR0_EL1, RES0_31, 31, 1) IDREG_FIELD_START(ID_AA64SMFR0_EL1, SF8FMA, 30, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1222,7 +1213,7 @@ IDREG_START(ID_AA64SMFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64SMFR0_EL1, SF8DP2) - IDREG_FIELD(ID_AA64SMFR0_EL1, RES0, 26, 2) + IDREG_FIELD(ID_AA64SMFR0_EL1, RES0_26, 26, 2) IDREG_FIELD_START(ID_AA64SMFR0_EL1, SBitPerm, 25, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1235,12 +1226,12 @@ IDREG_START(ID_AA64SMFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64SMFR0_EL1, SFEXPA) - IDREG_FIELD(ID_AA64SMFR0_EL1, RES0, 17, 6) + IDREG_FIELD(ID_AA64SMFR0_EL1, RES0_17, 17, 6) IDREG_FIELD_START(ID_AA64SMFR0_EL1, STMOP, 16, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64SMFR0_EL1, STMOP) - IDREG_FIELD(ID_AA64SMFR0_EL1, RES0, 1, 15) + IDREG_FIELD(ID_AA64SMFR0_EL1, RES0_1, 1, 15) IDREG_FIELD_START(ID_AA64SMFR0_EL1, SMOP4, 0, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1248,7 +1239,7 @@ IDREG_START(ID_AA64SMFR0_EL1) IDREG_END(ID_AA64SMFR0_EL1) IDREG_START(ID_AA64ZFR0_EL1) - IDREG_FIELD(ID_AA64ZFR0_EL1, RES0, 60, 4) + IDREG_FIELD(ID_AA64ZFR0_EL1, RES0_60, 60, 4) IDREG_FIELD_START(ID_AA64ZFR0_EL1, F64MM, 56, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1269,12 +1260,12 @@ IDREG_START(ID_AA64ZFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64ZFR0_EL1, SM4) - IDREG_FIELD(ID_AA64ZFR0_EL1, RES0, 36, 4) + IDREG_FIELD(ID_AA64ZFR0_EL1, RES0_36, 36, 4) IDREG_FIELD_START(ID_AA64ZFR0_EL1, SHA3, 32, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64ZFR0_EL1, SHA3) - IDREG_FIELD(ID_AA64ZFR0_EL1, RES0, 28, 4) + IDREG_FIELD(ID_AA64ZFR0_EL1, RES0_28, 28, 4) IDREG_FIELD_START(ID_AA64ZFR0_EL1, B16B16, 24, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1294,7 +1285,7 @@ IDREG_START(ID_AA64ZFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64ZFR0_EL1, EltPerm) - IDREG_FIELD(ID_AA64ZFR0_EL1, RES0, 8, 4) + IDREG_FIELD(ID_AA64ZFR0_EL1, RES0_8, 8, 4) IDREG_FIELD_START(ID_AA64ZFR0_EL1, AES, 4, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1311,11 +1302,11 @@ IDREG_START(ID_AA64ZFR0_EL1) IDREG_END(ID_AA64ZFR0_EL1) IDREG_START(ID_AFR0_EL1) - IDREG_FIELD(ID_AFR0_EL1, RES0, 0, 64) + IDREG_FIELD(ID_AFR0_EL1, RES0_0, 0, 64) IDREG_END(ID_AFR0_EL1) IDREG_START(ID_DFR0_EL1) - IDREG_FIELD(ID_DFR0_EL1, RES0, 32, 32) + IDREG_FIELD(ID_DFR0_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_DFR0_EL1, TraceFilt, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1367,7 +1358,7 @@ IDREG_START(ID_DFR0_EL1) IDREG_END(ID_DFR0_EL1) IDREG_START(ID_DFR1_EL1) - IDREG_FIELD(ID_DFR1_EL1, RES0, 8, 56) + IDREG_FIELD(ID_DFR1_EL1, RES0_8, 8, 56) IDREG_FIELD_START(ID_DFR1_EL1, HPMN0, 4, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1380,7 +1371,7 @@ IDREG_START(ID_DFR1_EL1) IDREG_END(ID_DFR1_EL1) IDREG_START(ID_ISAR0_EL1) - IDREG_FIELD(ID_ISAR0_EL1, RES0, 28, 36) + IDREG_FIELD(ID_ISAR0_EL1, RES0_28, 28, 36) IDREG_FIELD_START(ID_ISAR0_EL1, Divide, 24, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1416,7 +1407,7 @@ IDREG_START(ID_ISAR0_EL1) IDREG_END(ID_ISAR0_EL1) IDREG_START(ID_ISAR1_EL1) - IDREG_FIELD(ID_ISAR1_EL1, RES0, 32, 32) + IDREG_FIELD(ID_ISAR1_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_ISAR1_EL1, Jazelle, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1455,7 +1446,7 @@ IDREG_START(ID_ISAR1_EL1) IDREG_END(ID_ISAR1_EL1) IDREG_START(ID_ISAR2_EL1) - IDREG_FIELD(ID_ISAR2_EL1, RES0, 32, 32) + IDREG_FIELD(ID_ISAR2_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_ISAR2_EL1, Reversal, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1501,7 +1492,7 @@ IDREG_START(ID_ISAR2_EL1) IDREG_END(ID_ISAR2_EL1) IDREG_START(ID_ISAR3_EL1) - IDREG_FIELD(ID_ISAR3_EL1, RES0, 32, 32) + IDREG_FIELD(ID_ISAR3_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_ISAR3_EL1, T32EE, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1539,7 +1530,7 @@ IDREG_START(ID_ISAR3_EL1) IDREG_END(ID_ISAR3_EL1) IDREG_START(ID_ISAR4_EL1) - IDREG_FIELD(ID_ISAR4_EL1, RES0, 32, 32) + IDREG_FIELD(ID_ISAR4_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_ISAR4_EL1, SWP_frac, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1564,12 +1555,12 @@ IDREG_START(ID_ISAR4_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_ISAR4_EL1, Writeback) - IDREG_FIELD_START(ID_ISAR4_EL1, WI, 4, 4) + IDREG_FIELD_START(ID_ISAR4_EL1, WI_4, 4, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_ARCH_VAL(3) IDREG_FIELD_ARCH_VAL(4) - IDREG_FIELD_END(ID_ISAR4_EL1, WI) + IDREG_FIELD_END(ID_ISAR4_EL1, WI_4) IDREG_FIELD_START(ID_ISAR4_EL1, Unpriv, 0, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1578,7 +1569,7 @@ IDREG_START(ID_ISAR4_EL1) IDREG_END(ID_ISAR4_EL1) IDREG_START(ID_ISAR5_EL1) - IDREG_FIELD(ID_ISAR5_EL1, RES0, 32, 32) + IDREG_FIELD(ID_ISAR5_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_ISAR5_EL1, VCMA, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1587,7 +1578,7 @@ IDREG_START(ID_ISAR5_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_ISAR5_EL1, RDM) - IDREG_FIELD(ID_ISAR5_EL1, RES0, 20, 4) + IDREG_FIELD(ID_ISAR5_EL1, RES0_20, 20, 4) IDREG_FIELD_START(ID_ISAR5_EL1, CRC32, 16, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1612,7 +1603,7 @@ IDREG_START(ID_ISAR5_EL1) IDREG_END(ID_ISAR5_EL1) IDREG_START(ID_ISAR6_EL1) - IDREG_FIELD(ID_ISAR6_EL1, RES0, 32, 32) + IDREG_FIELD(ID_ISAR6_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_ISAR6_EL1, CLRBHB, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1649,7 +1640,7 @@ IDREG_START(ID_ISAR6_EL1) IDREG_END(ID_ISAR6_EL1) IDREG_START(ID_MMFR0_EL1) - IDREG_FIELD(ID_MMFR0_EL1, RES0, 32, 32) + IDREG_FIELD(ID_MMFR0_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_MMFR0_EL1, InnerShr, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1696,7 +1687,7 @@ IDREG_START(ID_MMFR0_EL1) IDREG_END(ID_MMFR0_EL1) IDREG_START(ID_MMFR1_EL1) - IDREG_FIELD(ID_MMFR1_EL1, RES0, 32, 32) + IDREG_FIELD(ID_MMFR1_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_MMFR1_EL1, BPred, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1745,7 +1736,7 @@ IDREG_START(ID_MMFR1_EL1) IDREG_END(ID_MMFR1_EL1) IDREG_START(ID_MMFR2_EL1) - IDREG_FIELD(ID_MMFR2_EL1, RES0, 32, 32) + IDREG_FIELD(ID_MMFR2_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_MMFR2_EL1, HWAccFlg, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1784,7 +1775,7 @@ IDREG_START(ID_MMFR2_EL1) IDREG_END(ID_MMFR2_EL1) IDREG_START(ID_MMFR3_EL1) - IDREG_FIELD(ID_MMFR3_EL1, RES0, 32, 32) + IDREG_FIELD(ID_MMFR3_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_MMFR3_EL1, Supersec, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(15)@@ -1824,7 +1815,7 @@ IDREG_START(ID_MMFR3_EL1) IDREG_END(ID_MMFR3_EL1) IDREG_START(ID_MMFR4_EL1) - IDREG_FIELD(ID_MMFR4_EL1, RES0, 32, 32) + IDREG_FIELD(ID_MMFR4_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_MMFR4_EL1, EVT, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1862,7 +1853,7 @@ IDREG_START(ID_MMFR4_EL1) IDREG_END(ID_MMFR4_EL1) IDREG_START(ID_MMFR5_EL1) - IDREG_FIELD(ID_MMFR5_EL1, RES0, 8, 56) + IDREG_FIELD(ID_MMFR5_EL1, RES0_8, 8, 56) IDREG_FIELD_START(ID_MMFR5_EL1, nTLBPA, 4, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1876,7 +1867,7 @@ IDREG_START(ID_MMFR5_EL1) IDREG_END(ID_MMFR5_EL1) IDREG_START(ID_PFR0_EL1) - IDREG_FIELD(ID_PFR0_EL1, RES0, 32, 32) + IDREG_FIELD(ID_PFR0_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_PFR0_EL1, RAS, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1918,7 +1909,7 @@ IDREG_START(ID_PFR0_EL1) IDREG_END(ID_PFR0_EL1) IDREG_START(ID_PFR1_EL1) - IDREG_FIELD(ID_PFR1_EL1, RES0, 32, 32) + IDREG_FIELD(ID_PFR1_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_PFR1_EL1, GIC, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1958,7 +1949,7 @@ IDREG_START(ID_PFR1_EL1) IDREG_END(ID_PFR1_EL1) IDREG_START(ID_PFR2_EL1) - IDREG_FIELD(ID_PFR2_EL1, RES0, 12, 52) + IDREG_FIELD(ID_PFR2_EL1, RES0_12, 12, 52) IDREG_FIELD_START(ID_PFR2_EL1, RAS_frac, 8, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -2006,14 +1997,14 @@ IDREG_START(MIDR_EL1) IDREG_END(MIDR_EL1) IDREG_START(MPIDR_EL1) - IDREG_FIELD(MPIDR_EL1, RES0, 40, 24) + IDREG_FIELD(MPIDR_EL1, RES0_40, 40, 24) IDREG_FIELD(MPIDR_EL1, Aff3, 32, 8) - IDREG_FIELD(MPIDR_EL1, RES1, 31, 1) + IDREG_FIELD(MPIDR_EL1, RES1_31, 31, 1) IDREG_FIELD_START(MPIDR_EL1, U, 30, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(MPIDR_EL1, U) - IDREG_FIELD(MPIDR_EL1, RES0, 25, 5) + IDREG_FIELD(MPIDR_EL1, RES0_25, 25, 5) IDREG_FIELD_START(MPIDR_EL1, MT, 24, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -2024,7 +2015,7 @@ IDREG_START(MPIDR_EL1) IDREG_END(MPIDR_EL1) IDREG_START(MVFR0_EL1) - IDREG_FIELD(MVFR0_EL1, RES0, 32, 32) + IDREG_FIELD(MVFR0_EL1, RES0_32, 32, 32) IDREG_FIELD_START(MVFR0_EL1, FPRound, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -2063,7 +2054,7 @@ IDREG_START(MVFR0_EL1) IDREG_END(MVFR0_EL1) IDREG_START(MVFR1_EL1) - IDREG_FIELD(MVFR1_EL1, RES0, 32, 32) + IDREG_FIELD(MVFR1_EL1, RES0_32, 32, 32) IDREG_FIELD_START(MVFR1_EL1, SIMDFMAC, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -2102,7 +2093,7 @@ IDREG_START(MVFR1_EL1) IDREG_END(MVFR1_EL1) IDREG_START(MVFR2_EL1) - IDREG_FIELD(MVFR2_EL1, RES0, 8, 56) + IDREG_FIELD(MVFR2_EL1, RES0_8, 8, 56) IDREG_FIELD_START(MVFR2_EL1, FPMisc, 4, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -2119,17 +2110,13 @@ IDREG_START(MVFR2_EL1) IDREG_END(MVFR2_EL1) IDREG_START(REVIDR_EL1) + IDREG_FIELD(REVIDR_EL1, VAL, 0, 64) IDREG_END(REVIDR_EL1) IDREG_START(SMIDR_EL1) - IDREG_FIELD(SMIDR_EL1, RES0, 60, 4)
target/arm/cpu-idregs.h.inc IDREG_START(MVFR2_EL1) · line 2119
Quoted 10 lines
target/arm/cpu-idregs.h.inc +3
-7- IDREG_FIELD_START(SMIDR_EL1, NSMC, 56, 4) - IDREG_FIELD_ARCH_VAL(0) - IDREG_FIELD_ARCH_VAL(15) - IDREG_FIELD_END(SMIDR_EL1, NSMC) - IDREG_FIELD_START(SMIDR_EL1, HIP, 52, 4) - IDREG_FIELD_ARCH_VAL(0) - IDREG_FIELD_END(SMIDR_EL1, HIP) + IDREG_FIELD(SMIDR_EL1, RES0_60, 60, 4) + IDREG_FIELD(SMIDR_EL1, NSMC, 56, 4) + IDREG_FIELD(SMIDR_EL1, HIP, 52, 4)
so this looks wrong to me. I fixed that in v7
Quoted 12 lines
target/arm/cpu-idregs.h.inc +1
-1IDREG_FIELD(SMIDR_EL1, Affinity2, 32, 20) IDREG_FIELD_START(SMIDR_EL1, Implementer, 24, 8) IDREG_FIELD_ARCH_VAL(0)@@ -2158,7 +2145,7 @@ IDREG_START(SMIDR_EL1) IDREG_FIELD_ARCH_VAL(2) IDREG_FIELD_ARCH_VAL(3) IDREG_FIELD_END(SMIDR_EL1, SH) - IDREG_FIELD(SMIDR_EL1, RES0, 12, 1) + IDREG_FIELD(SMIDR_EL1, RES0_12, 12, 1) IDREG_FIELD(SMIDR_EL1, Affinity, 0, 12) IDREG_END(SMIDR_EL1)
Re: [RFC PATCH v3 03/19] target/arm: regenerate cpu-idregs.h.inc
Quoted 582 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 87 lines · Khushit Shah
Signed-off-by Khushit Shah <[email protected]>---
target/arm/cpu-idregs.h.inc | 165 +++++++++++++++++-------------------1 file changed, 76 insertions(+), 89 deletions(-)target/arm/cpu-idregs.h.inc +13
-12@@ -12,23 +12,24 @@ /* IDREG_END(REG) */ IDREG_START(AIDR_EL1) + IDREG_FIELD(AIDR_EL1, VAL, 0, 64) IDREG_END(AIDR_EL1) IDREG_START(CCSIDR2_EL1) - IDREG_FIELD(CCSIDR2_EL1, RES0, 24, 40) + IDREG_FIELD(CCSIDR2_EL1, RES0_24, 24, 40) IDREG_FIELD(CCSIDR2_EL1, NumSets, 0, 24) IDREG_END(CCSIDR2_EL1) IDREG_START(CCSIDR_EL1) - IDREG_FIELD(CCSIDR_EL1, RES0, 56, 8) + IDREG_FIELD(CCSIDR_EL1, RES0_56, 56, 8) IDREG_FIELD(CCSIDR_EL1, NumSets, 32, 24) - IDREG_FIELD(CCSIDR_EL1, RES0, 24, 8) + IDREG_FIELD(CCSIDR_EL1, RES0_24, 24, 8) IDREG_FIELD(CCSIDR_EL1, Associativity, 3, 21) IDREG_FIELD(CCSIDR_EL1, LineSize, 0, 3) IDREG_END(CCSIDR_EL1) IDREG_START(CLIDR_EL1) - IDREG_FIELD(CLIDR_EL1, RES0, 47, 17) + IDREG_FIELD(CLIDR_EL1, RES0_47, 47, 17) IDREG_FIELD(CLIDR_EL1, Ttype7, 45, 2) IDREG_FIELD(CLIDR_EL1, Ttype6, 43, 2) IDREG_FIELD(CLIDR_EL1, Ttype5, 41, 2)@@ -59,10 +60,10 @@ IDREG_START(CLIDR_EL1) IDREG_END(CLIDR_EL1) IDREG_START(CTR_EL0) - IDREG_FIELD(CTR_EL0, RES0, 38, 26) + IDREG_FIELD(CTR_EL0, RES0_38, 38, 26) IDREG_FIELD(CTR_EL0, TminLine, 32, 6) - IDREG_FIELD(CTR_EL0, RES1, 31, 1) - IDREG_FIELD(CTR_EL0, RES0, 30, 1) + IDREG_FIELD(CTR_EL0, RES1_31, 31, 1) + IDREG_FIELD(CTR_EL0, RES0_30, 30, 1) IDREG_FIELD_START(CTR_EL0, DIC, 29, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -80,28 +81,28 @@ IDREG_START(CTR_EL0) IDREG_FIELD_ARCH_VAL(2) IDREG_FIELD_ARCH_VAL(3) IDREG_FIELD_END(CTR_EL0, L1Ip) - IDREG_FIELD(CTR_EL0, RES0, 4, 10) + IDREG_FIELD(CTR_EL0, RES0_4, 4, 10) IDREG_FIELD(CTR_EL0, IminLine, 0, 4) IDREG_END(CTR_EL0) IDREG_START(DCZID_EL0) - IDREG_FIELD(DCZID_EL0, RES0, 9, 55) + IDREG_FIELD(DCZID_EL0, RES0_9, 9, 55) IDREG_FIELD(DCZID_EL0, TBS, 5, 4) IDREG_FIELD(DCZID_EL0, DZP, 4, 1) IDREG_FIELD(DCZID_EL0, BS, 0, 4) IDREG_END(DCZID_EL0) IDREG_START(GMID_EL1) - IDREG_FIELD(GMID_EL1, RES0, 4, 60) + IDREG_FIELD(GMID_EL1, RES0_4, 4, 60) IDREG_FIELD(GMID_EL1, BS, 0, 4) IDREG_END(GMID_EL1) IDREG_START(ID_AA64AFR0_EL1) - IDREG_FIELD(ID_AA64AFR0_EL1, RES0, 32, 32) + IDREG_FIELD(ID_AA64AFR0_EL1, RES0_32, 32, 32) IDREG_END(ID_AA64AFR0_EL1) IDREG_START(ID_AA64AFR1_EL1) - IDREG_FIELD(ID_AA64AFR1_EL1, RES0, 0, 64) + IDREG_FIELD(ID_AA64AFR1_EL1, RES0_0, 0, 64) IDREG_END(ID_AA64AFR1_EL1) IDREG_START(ID_AA64DFR0_EL1)target/arm/cpu-idregs.h.inc IDREG_START(ID_AA64DFR0_EL1) · line 149
Quoted 8 lines
target/arm/cpu-idregs.h.inc +1
-4@@ -145,18 +146,14 @@ IDREG_START(ID_AA64DFR0_EL1) IDREG_FIELD_ARCH_VAL(5) IDREG_FIELD_ARCH_VAL(6) IDREG_FIELD_END(ID_AA64DFR0_EL1, PMSVer) - IDREG_FIELD_START(ID_AA64DFR0_EL1, CTX_CMPs, 28, 4) - IDREG_FIELD_ARCH_VAL(15) - IDREG_FIELD_END(ID_AA64DFR0_EL1, CTX_CMPs) - IDREG_FIELD(ID_AA64DFR0_EL1, RES0, 24, 4) + IDREG_FIELD(ID_AA64DFR0_EL1, CTX_CMPs, 28, 4)so it seems you remove all the ARCH values found in ValueRange (by the way there were incomplete)
EricQuoted 472 lines
target/arm/cpu-idregs.h.inc +58
-64+ IDREG_FIELD(ID_AA64DFR0_EL1, RES0_24, 24, 4) IDREG_FIELD(ID_AA64DFR0_EL1, WRPs, 20, 4) IDREG_FIELD_START(ID_AA64DFR0_EL1, PMSS, 16, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64DFR0_EL1, PMSS) - IDREG_FIELD_START(ID_AA64DFR0_EL1, BRPs, 12, 4) - IDREG_FIELD_ARCH_VAL(15) - IDREG_FIELD_END(ID_AA64DFR0_EL1, BRPs) + IDREG_FIELD(ID_AA64DFR0_EL1, BRPs, 12, 4) IDREG_FIELD_START(ID_AA64DFR0_EL1, PMUVer, 8, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -209,20 +206,14 @@ IDREG_START(ID_AA64DFR1_EL1) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_ARCH_VAL(2) IDREG_FIELD_END(ID_AA64DFR1_EL1, SPMU) - IDREG_FIELD_START(ID_AA64DFR1_EL1, CTX_CMPs, 24, 8) - IDREG_FIELD_ARCH_VAL(0) - IDREG_FIELD_END(ID_AA64DFR1_EL1, CTX_CMPs) - IDREG_FIELD_START(ID_AA64DFR1_EL1, WRPs, 16, 8) - IDREG_FIELD_ARCH_VAL(0) - IDREG_FIELD_END(ID_AA64DFR1_EL1, WRPs) - IDREG_FIELD_START(ID_AA64DFR1_EL1, BRPs, 8, 8) - IDREG_FIELD_ARCH_VAL(0) - IDREG_FIELD_END(ID_AA64DFR1_EL1, BRPs) + IDREG_FIELD(ID_AA64DFR1_EL1, CTX_CMPs, 24, 8) + IDREG_FIELD(ID_AA64DFR1_EL1, WRPs, 16, 8) + IDREG_FIELD(ID_AA64DFR1_EL1, BRPs, 8, 8) IDREG_FIELD(ID_AA64DFR1_EL1, SYSPMUID, 0, 8) IDREG_END(ID_AA64DFR1_EL1) IDREG_START(ID_AA64DFR2_EL1) - IDREG_FIELD(ID_AA64DFR2_EL1, RES0, 28, 36) + IDREG_FIELD(ID_AA64DFR2_EL1, RES0_28, 28, 36) IDREG_FIELD_START(ID_AA64DFR2_EL1, TRBE_EXC, 24, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -235,7 +226,7 @@ IDREG_START(ID_AA64DFR2_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64DFR2_EL1, SPE_EXC) - IDREG_FIELD(ID_AA64DFR2_EL1, RES0, 8, 8) + IDREG_FIELD(ID_AA64DFR2_EL1, RES0_8, 8, 8) IDREG_FIELD_START(ID_AA64DFR2_EL1, BWE, 4, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -248,7 +239,7 @@ IDREG_START(ID_AA64DFR2_EL1) IDREG_END(ID_AA64DFR2_EL1) IDREG_START(ID_AA64FPFR0_EL1) - IDREG_FIELD(ID_AA64FPFR0_EL1, RES0, 32, 32) + IDREG_FIELD(ID_AA64FPFR0_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_AA64FPFR0_EL1, F8CVT, 31, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -273,13 +264,13 @@ IDREG_START(ID_AA64FPFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64FPFR0_EL1, F8MM4) - IDREG_FIELD(ID_AA64FPFR0_EL1, RES0, 16, 10) + IDREG_FIELD(ID_AA64FPFR0_EL1, RES0_16, 16, 10) IDREG_FIELD_START(ID_AA64FPFR0_EL1, F16MM2, 15, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64FPFR0_EL1, F16MM2) - IDREG_FIELD(ID_AA64FPFR0_EL1, RES0, 8, 7) - IDREG_FIELD(ID_AA64FPFR0_EL1, RAZ, 2, 6) + IDREG_FIELD(ID_AA64FPFR0_EL1, RES0_8, 8, 7) + IDREG_FIELD(ID_AA64FPFR0_EL1, RAZ_2, 2, 6) IDREG_FIELD_START(ID_AA64FPFR0_EL1, F8E4M3, 1, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -331,7 +322,7 @@ IDREG_START(ID_AA64ISAR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64ISAR0_EL1, RDM) - IDREG_FIELD(ID_AA64ISAR0_EL1, RES0, 24, 4) + IDREG_FIELD(ID_AA64ISAR0_EL1, RES0_24, 24, 4) IDREG_FIELD_START(ID_AA64ISAR0_EL1, Atomic, 20, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(2)@@ -355,7 +346,7 @@ IDREG_START(ID_AA64ISAR0_EL1) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_ARCH_VAL(2) IDREG_FIELD_END(ID_AA64ISAR0_EL1, AES) - IDREG_FIELD(ID_AA64ISAR0_EL1, RES0, 0, 4) + IDREG_FIELD(ID_AA64ISAR0_EL1, RES0_0, 0, 4) IDREG_END(ID_AA64ISAR0_EL1) IDREG_START(ID_AA64ISAR1_EL1)@@ -519,7 +510,7 @@ IDREG_START(ID_AA64ISAR2_EL1) IDREG_END(ID_AA64ISAR2_EL1) IDREG_START(ID_AA64ISAR3_EL1) - IDREG_FIELD(ID_AA64ISAR3_EL1, RES0, 48, 16) + IDREG_FIELD(ID_AA64ISAR3_EL1, RES0_48, 48, 16) IDREG_FIELD_START(ID_AA64ISAR3_EL1, LSCP, 44, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -583,7 +574,7 @@ IDREG_START(ID_AA64MMFR0_EL1) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_ARCH_VAL(2) IDREG_FIELD_END(ID_AA64MMFR0_EL1, FGT) - IDREG_FIELD(ID_AA64MMFR0_EL1, RES0, 48, 8) + IDREG_FIELD(ID_AA64MMFR0_EL1, RES0_48, 48, 8) IDREG_FIELD_START(ID_AA64MMFR0_EL1, ExS, 44, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -736,7 +727,7 @@ IDREG_START(ID_AA64MMFR2_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64MMFR2_EL1, TTL) - IDREG_FIELD(ID_AA64MMFR2_EL1, RES0, 44, 4) + IDREG_FIELD(ID_AA64MMFR2_EL1, RES0_44, 44, 4) IDREG_FIELD_START(ID_AA64MMFR2_EL1, FWB, 40, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -802,7 +793,7 @@ IDREG_START(ID_AA64MMFR3_EL1) IDREG_FIELD_ARCH_VAL(2) IDREG_FIELD_ARCH_VAL(3) IDREG_FIELD_END(ID_AA64MMFR3_EL1, SDERR) - IDREG_FIELD(ID_AA64MMFR3_EL1, RES0, 48, 4) + IDREG_FIELD(ID_AA64MMFR3_EL1, RES0_48, 48, 4) IDREG_FIELD_START(ID_AA64MMFR3_EL1, ANERR, 44, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1056,7 +1047,7 @@ IDREG_START(ID_AA64PFR1_EL1) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_ARCH_VAL(2) IDREG_FIELD_END(ID_AA64PFR1_EL1, SME) - IDREG_FIELD(ID_AA64PFR1_EL1, RES0, 20, 4) + IDREG_FIELD(ID_AA64PFR1_EL1, RES0_20, 20, 4) IDREG_FIELD_START(ID_AA64PFR1_EL1, MPAM_frac, 16, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1084,7 +1075,7 @@ IDREG_START(ID_AA64PFR1_EL1) IDREG_END(ID_AA64PFR1_EL1) IDREG_START(ID_AA64PFR2_EL1) - IDREG_FIELD(ID_AA64PFR2_EL1, RES0, 48, 16) + IDREG_FIELD(ID_AA64PFR2_EL1, RES0_48, 48, 16) IDREG_FIELD_START(ID_AA64PFR2_EL1, VMTETCL, 44, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1144,7 +1135,7 @@ IDREG_START(ID_AA64SMFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64SMFR0_EL1, FA64) - IDREG_FIELD(ID_AA64SMFR0_EL1, RES0, 62, 1) + IDREG_FIELD(ID_AA64SMFR0_EL1, RES0_62, 62, 1) IDREG_FIELD_START(ID_AA64SMFR0_EL1, LUT6, 61, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1164,7 +1155,7 @@ IDREG_START(ID_AA64SMFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(15) IDREG_FIELD_END(ID_AA64SMFR0_EL1, I16I64) - IDREG_FIELD(ID_AA64SMFR0_EL1, RES0, 49, 3) + IDREG_FIELD(ID_AA64SMFR0_EL1, RES0_49, 49, 3) IDREG_FIELD_START(ID_AA64SMFR0_EL1, F64F64, 48, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1209,7 +1200,7 @@ IDREG_START(ID_AA64SMFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64SMFR0_EL1, F32F32) - IDREG_FIELD(ID_AA64SMFR0_EL1, RES0, 31, 1) + IDREG_FIELD(ID_AA64SMFR0_EL1, RES0_31, 31, 1) IDREG_FIELD_START(ID_AA64SMFR0_EL1, SF8FMA, 30, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1222,7 +1213,7 @@ IDREG_START(ID_AA64SMFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64SMFR0_EL1, SF8DP2) - IDREG_FIELD(ID_AA64SMFR0_EL1, RES0, 26, 2) + IDREG_FIELD(ID_AA64SMFR0_EL1, RES0_26, 26, 2) IDREG_FIELD_START(ID_AA64SMFR0_EL1, SBitPerm, 25, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1235,12 +1226,12 @@ IDREG_START(ID_AA64SMFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64SMFR0_EL1, SFEXPA) - IDREG_FIELD(ID_AA64SMFR0_EL1, RES0, 17, 6) + IDREG_FIELD(ID_AA64SMFR0_EL1, RES0_17, 17, 6) IDREG_FIELD_START(ID_AA64SMFR0_EL1, STMOP, 16, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64SMFR0_EL1, STMOP) - IDREG_FIELD(ID_AA64SMFR0_EL1, RES0, 1, 15) + IDREG_FIELD(ID_AA64SMFR0_EL1, RES0_1, 1, 15) IDREG_FIELD_START(ID_AA64SMFR0_EL1, SMOP4, 0, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1248,7 +1239,7 @@ IDREG_START(ID_AA64SMFR0_EL1) IDREG_END(ID_AA64SMFR0_EL1) IDREG_START(ID_AA64ZFR0_EL1) - IDREG_FIELD(ID_AA64ZFR0_EL1, RES0, 60, 4) + IDREG_FIELD(ID_AA64ZFR0_EL1, RES0_60, 60, 4) IDREG_FIELD_START(ID_AA64ZFR0_EL1, F64MM, 56, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1269,12 +1260,12 @@ IDREG_START(ID_AA64ZFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64ZFR0_EL1, SM4) - IDREG_FIELD(ID_AA64ZFR0_EL1, RES0, 36, 4) + IDREG_FIELD(ID_AA64ZFR0_EL1, RES0_36, 36, 4) IDREG_FIELD_START(ID_AA64ZFR0_EL1, SHA3, 32, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64ZFR0_EL1, SHA3) - IDREG_FIELD(ID_AA64ZFR0_EL1, RES0, 28, 4) + IDREG_FIELD(ID_AA64ZFR0_EL1, RES0_28, 28, 4) IDREG_FIELD_START(ID_AA64ZFR0_EL1, B16B16, 24, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1294,7 +1285,7 @@ IDREG_START(ID_AA64ZFR0_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_AA64ZFR0_EL1, EltPerm) - IDREG_FIELD(ID_AA64ZFR0_EL1, RES0, 8, 4) + IDREG_FIELD(ID_AA64ZFR0_EL1, RES0_8, 8, 4) IDREG_FIELD_START(ID_AA64ZFR0_EL1, AES, 4, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1311,11 +1302,11 @@ IDREG_START(ID_AA64ZFR0_EL1) IDREG_END(ID_AA64ZFR0_EL1) IDREG_START(ID_AFR0_EL1) - IDREG_FIELD(ID_AFR0_EL1, RES0, 0, 64) + IDREG_FIELD(ID_AFR0_EL1, RES0_0, 0, 64) IDREG_END(ID_AFR0_EL1) IDREG_START(ID_DFR0_EL1) - IDREG_FIELD(ID_DFR0_EL1, RES0, 32, 32) + IDREG_FIELD(ID_DFR0_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_DFR0_EL1, TraceFilt, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1367,7 +1358,7 @@ IDREG_START(ID_DFR0_EL1) IDREG_END(ID_DFR0_EL1) IDREG_START(ID_DFR1_EL1) - IDREG_FIELD(ID_DFR1_EL1, RES0, 8, 56) + IDREG_FIELD(ID_DFR1_EL1, RES0_8, 8, 56) IDREG_FIELD_START(ID_DFR1_EL1, HPMN0, 4, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1380,7 +1371,7 @@ IDREG_START(ID_DFR1_EL1) IDREG_END(ID_DFR1_EL1) IDREG_START(ID_ISAR0_EL1) - IDREG_FIELD(ID_ISAR0_EL1, RES0, 28, 36) + IDREG_FIELD(ID_ISAR0_EL1, RES0_28, 28, 36) IDREG_FIELD_START(ID_ISAR0_EL1, Divide, 24, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1416,7 +1407,7 @@ IDREG_START(ID_ISAR0_EL1) IDREG_END(ID_ISAR0_EL1) IDREG_START(ID_ISAR1_EL1) - IDREG_FIELD(ID_ISAR1_EL1, RES0, 32, 32) + IDREG_FIELD(ID_ISAR1_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_ISAR1_EL1, Jazelle, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1455,7 +1446,7 @@ IDREG_START(ID_ISAR1_EL1) IDREG_END(ID_ISAR1_EL1) IDREG_START(ID_ISAR2_EL1) - IDREG_FIELD(ID_ISAR2_EL1, RES0, 32, 32) + IDREG_FIELD(ID_ISAR2_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_ISAR2_EL1, Reversal, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1501,7 +1492,7 @@ IDREG_START(ID_ISAR2_EL1) IDREG_END(ID_ISAR2_EL1) IDREG_START(ID_ISAR3_EL1) - IDREG_FIELD(ID_ISAR3_EL1, RES0, 32, 32) + IDREG_FIELD(ID_ISAR3_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_ISAR3_EL1, T32EE, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1539,7 +1530,7 @@ IDREG_START(ID_ISAR3_EL1) IDREG_END(ID_ISAR3_EL1) IDREG_START(ID_ISAR4_EL1) - IDREG_FIELD(ID_ISAR4_EL1, RES0, 32, 32) + IDREG_FIELD(ID_ISAR4_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_ISAR4_EL1, SWP_frac, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1564,12 +1555,12 @@ IDREG_START(ID_ISAR4_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_ISAR4_EL1, Writeback) - IDREG_FIELD_START(ID_ISAR4_EL1, WI, 4, 4) + IDREG_FIELD_START(ID_ISAR4_EL1, WI_4, 4, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_ARCH_VAL(3) IDREG_FIELD_ARCH_VAL(4) - IDREG_FIELD_END(ID_ISAR4_EL1, WI) + IDREG_FIELD_END(ID_ISAR4_EL1, WI_4) IDREG_FIELD_START(ID_ISAR4_EL1, Unpriv, 0, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1578,7 +1569,7 @@ IDREG_START(ID_ISAR4_EL1) IDREG_END(ID_ISAR4_EL1) IDREG_START(ID_ISAR5_EL1) - IDREG_FIELD(ID_ISAR5_EL1, RES0, 32, 32) + IDREG_FIELD(ID_ISAR5_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_ISAR5_EL1, VCMA, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1587,7 +1578,7 @@ IDREG_START(ID_ISAR5_EL1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(ID_ISAR5_EL1, RDM) - IDREG_FIELD(ID_ISAR5_EL1, RES0, 20, 4) + IDREG_FIELD(ID_ISAR5_EL1, RES0_20, 20, 4) IDREG_FIELD_START(ID_ISAR5_EL1, CRC32, 16, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1612,7 +1603,7 @@ IDREG_START(ID_ISAR5_EL1) IDREG_END(ID_ISAR5_EL1) IDREG_START(ID_ISAR6_EL1) - IDREG_FIELD(ID_ISAR6_EL1, RES0, 32, 32) + IDREG_FIELD(ID_ISAR6_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_ISAR6_EL1, CLRBHB, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1649,7 +1640,7 @@ IDREG_START(ID_ISAR6_EL1) IDREG_END(ID_ISAR6_EL1) IDREG_START(ID_MMFR0_EL1) - IDREG_FIELD(ID_MMFR0_EL1, RES0, 32, 32) + IDREG_FIELD(ID_MMFR0_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_MMFR0_EL1, InnerShr, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1696,7 +1687,7 @@ IDREG_START(ID_MMFR0_EL1) IDREG_END(ID_MMFR0_EL1) IDREG_START(ID_MMFR1_EL1) - IDREG_FIELD(ID_MMFR1_EL1, RES0, 32, 32) + IDREG_FIELD(ID_MMFR1_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_MMFR1_EL1, BPred, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1745,7 +1736,7 @@ IDREG_START(ID_MMFR1_EL1) IDREG_END(ID_MMFR1_EL1) IDREG_START(ID_MMFR2_EL1) - IDREG_FIELD(ID_MMFR2_EL1, RES0, 32, 32) + IDREG_FIELD(ID_MMFR2_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_MMFR2_EL1, HWAccFlg, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1784,7 +1775,7 @@ IDREG_START(ID_MMFR2_EL1) IDREG_END(ID_MMFR2_EL1) IDREG_START(ID_MMFR3_EL1) - IDREG_FIELD(ID_MMFR3_EL1, RES0, 32, 32) + IDREG_FIELD(ID_MMFR3_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_MMFR3_EL1, Supersec, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(15)@@ -1824,7 +1815,7 @@ IDREG_START(ID_MMFR3_EL1) IDREG_END(ID_MMFR3_EL1) IDREG_START(ID_MMFR4_EL1) - IDREG_FIELD(ID_MMFR4_EL1, RES0, 32, 32) + IDREG_FIELD(ID_MMFR4_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_MMFR4_EL1, EVT, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1862,7 +1853,7 @@ IDREG_START(ID_MMFR4_EL1) IDREG_END(ID_MMFR4_EL1) IDREG_START(ID_MMFR5_EL1) - IDREG_FIELD(ID_MMFR5_EL1, RES0, 8, 56) + IDREG_FIELD(ID_MMFR5_EL1, RES0_8, 8, 56) IDREG_FIELD_START(ID_MMFR5_EL1, nTLBPA, 4, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1876,7 +1867,7 @@ IDREG_START(ID_MMFR5_EL1) IDREG_END(ID_MMFR5_EL1) IDREG_START(ID_PFR0_EL1) - IDREG_FIELD(ID_PFR0_EL1, RES0, 32, 32) + IDREG_FIELD(ID_PFR0_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_PFR0_EL1, RAS, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1918,7 +1909,7 @@ IDREG_START(ID_PFR0_EL1) IDREG_END(ID_PFR0_EL1) IDREG_START(ID_PFR1_EL1) - IDREG_FIELD(ID_PFR1_EL1, RES0, 32, 32) + IDREG_FIELD(ID_PFR1_EL1, RES0_32, 32, 32) IDREG_FIELD_START(ID_PFR1_EL1, GIC, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -1958,7 +1949,7 @@ IDREG_START(ID_PFR1_EL1) IDREG_END(ID_PFR1_EL1) IDREG_START(ID_PFR2_EL1) - IDREG_FIELD(ID_PFR2_EL1, RES0, 12, 52) + IDREG_FIELD(ID_PFR2_EL1, RES0_12, 12, 52) IDREG_FIELD_START(ID_PFR2_EL1, RAS_frac, 8, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -2006,14 +1997,14 @@ IDREG_START(MIDR_EL1) IDREG_END(MIDR_EL1) IDREG_START(MPIDR_EL1) - IDREG_FIELD(MPIDR_EL1, RES0, 40, 24) + IDREG_FIELD(MPIDR_EL1, RES0_40, 40, 24) IDREG_FIELD(MPIDR_EL1, Aff3, 32, 8) - IDREG_FIELD(MPIDR_EL1, RES1, 31, 1) + IDREG_FIELD(MPIDR_EL1, RES1_31, 31, 1) IDREG_FIELD_START(MPIDR_EL1, U, 30, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1) IDREG_FIELD_END(MPIDR_EL1, U) - IDREG_FIELD(MPIDR_EL1, RES0, 25, 5) + IDREG_FIELD(MPIDR_EL1, RES0_25, 25, 5) IDREG_FIELD_START(MPIDR_EL1, MT, 24, 1) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -2024,7 +2015,7 @@ IDREG_START(MPIDR_EL1) IDREG_END(MPIDR_EL1) IDREG_START(MVFR0_EL1) - IDREG_FIELD(MVFR0_EL1, RES0, 32, 32) + IDREG_FIELD(MVFR0_EL1, RES0_32, 32, 32) IDREG_FIELD_START(MVFR0_EL1, FPRound, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -2063,7 +2054,7 @@ IDREG_START(MVFR0_EL1) IDREG_END(MVFR0_EL1) IDREG_START(MVFR1_EL1) - IDREG_FIELD(MVFR1_EL1, RES0, 32, 32) + IDREG_FIELD(MVFR1_EL1, RES0_32, 32, 32) IDREG_FIELD_START(MVFR1_EL1, SIMDFMAC, 28, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -2102,7 +2093,7 @@ IDREG_START(MVFR1_EL1) IDREG_END(MVFR1_EL1) IDREG_START(MVFR2_EL1) - IDREG_FIELD(MVFR2_EL1, RES0, 8, 56) + IDREG_FIELD(MVFR2_EL1, RES0_8, 8, 56) IDREG_FIELD_START(MVFR2_EL1, FPMisc, 4, 4) IDREG_FIELD_ARCH_VAL(0) IDREG_FIELD_ARCH_VAL(1)@@ -2119,17 +2110,13 @@ IDREG_START(MVFR2_EL1) IDREG_END(MVFR2_EL1) IDREG_START(REVIDR_EL1) + IDREG_FIELD(REVIDR_EL1, VAL, 0, 64) IDREG_END(REVIDR_EL1)
Quoted 13 lines
target/arm/cpu-idregs.h.inc IDREG_START(MVFR2_EL1) · line 2119
Quoted 12 lines
target/arm/cpu-idregs.h.inc +3
-8IDREG_START(SMIDR_EL1) - IDREG_FIELD(SMIDR_EL1, RES0, 60, 4) - IDREG_FIELD_START(SMIDR_EL1, NSMC, 56, 4) - IDREG_FIELD_ARCH_VAL(0) - IDREG_FIELD_ARCH_VAL(15) - IDREG_FIELD_END(SMIDR_EL1, NSMC) - IDREG_FIELD_START(SMIDR_EL1, HIP, 52, 4) - IDREG_FIELD_ARCH_VAL(0) - IDREG_FIELD_END(SMIDR_EL1, HIP) + IDREG_FIELD(SMIDR_EL1, RES0_60, 60, 4) + IDREG_FIELD(SMIDR_EL1, NSMC, 56, 4) + IDREG_FIELD(SMIDR_EL1, HIP, 52, 4)so this looks wrong to me. I fixed that in v7
Thanks!
Warm Regards,
Khushit
Quoted 11 lines
Quoted 11 lines
target/arm/cpu-idregs.h.inc +1
-1IDREG_FIELD(SMIDR_EL1, Affinity2, 32, 20) IDREG_FIELD_START(SMIDR_EL1, Implementer, 24, 8) IDREG_FIELD_ARCH_VAL(0)@@ -2158,7 +2145,7 @@ IDREG_START(SMIDR_EL1) IDREG_FIELD_ARCH_VAL(2) IDREG_FIELD_ARCH_VAL(3) IDREG_FIELD_END(SMIDR_EL1, SH) - IDREG_FIELD(SMIDR_EL1, RES0, 12, 1) + IDREG_FIELD(SMIDR_EL1, RES0_12, 12, 1) IDREG_FIELD(SMIDR_EL1, Affinity, 0, 12) IDREG_END(SMIDR_EL1)
RFC PATCH v3 4/19 target/arm: expose all ID regs fields as properties
In reply to Khushit ShahUpcoming named cpu models layer requires exposing all the ID register fields as properties.
While doing so also move the code to cpu64.c to make it accelerator-agnostic, and rename the function to aarch64_add_idregs_properties().
This makes porting this solution to other accelerators easy in future.
--- target/arm/cpu64.c | 116 +++++++++++++++++++++++++++++- target/arm/internals.h | 3 + target/arm/kvm.c | 151 ---------------------------------------- target/arm/kvm_arm.h | 8 --- target/arm/trace-events | 4 +- 5 files changed, 119 insertions(+), 163 deletions(-)
target/arm/cpu64.c +114 -2
@@ -38,6 +38,7 @@#include "internals.h" #include "cpu-features.h" #include "cpu-idregs.h" +#include "trace.h" /* convert between <register>_IDX and SYS_<register> */ #define DEF (NAME ,OP0 ,OP1 ,CRN ,CRM ,OP2 ) \
@@ -644,6 +645,113 @@ static const Property arm_cpu_pauth_qarma3_property =static Property arm_cpu_pauth_qarma5_property =DEFINE_PROP_BOOL ("pauth-qarma5" ,ARMCPU , prop_pauth_qarma5, false); +#ifndef CONFIG_USER_ONLY +static void set_sysreg_prop (Object *obj,Visitor *v, +const char *name,void *opaque, +Error **errp) +{ +ARM64SysRegField *field = (ARM64SysRegField *)opaque; +ARMCPU *cpu =ARM_CPU (obj); +uint64_t *idregs = cpu->isar.idregs; +uint64_t old, value, mask; +int lower = field->shift; +int length = field->length; +int index = field->index; + +if (!visit_type_uint64 (v, name, &value, errp)) { +return ; + } + +if (length <64 && value > ((1ULL << length) -1 )) { +error_setg (errp, +"idreg %s set value (0x%lx) exceeds length of field (%d)!" , + name, value, length); +return ; + } + +if (field->arch_vals) { +/* this field has some enum values */ +for (int i =0 ; i < field->arch_vals_count; i++) { +if (value == field->arch_vals[i].value) { + goto valid; + } + } +error_setg (errp, +"idreg %s set value (0x%lx) does not match any " +"arch valid enum value!" , name, value); +return ; + } + +/* If the field is RESx or RAZ, it should not be written anything else */ +if (strstr (field->name,"RES0" ) && value !=0 ) { +error_setg (errp,"idreg %s is RES0 field and cannot write %ld" , + name, value); +return ; + }else if (strstr (field->name,"RAZ" ) && value !=0 ) { +error_setg (errp,"idreg %s is RAZ field and cannot write %ld" , + name, value); +return ; + }else if (strstr (field->name,"RES1" ) && value !=1 ) { +error_setg (errp,"idreg %s is RES1 field and cannot write %ld" , + name, value); +return ; + } + +valid: + mask =MAKE_64BIT_MASK (lower, length); + value = value << lower; + old = idregs[index]; + idregs[index] = old & ~mask; + idregs[index] |= value; +trace_set_sysreg_prop (name, old, mask, value, idregs[index]); +} + +static void get_sysreg_prop (Object *obj,Visitor *v, +const char *name,void *opaque, +Error **errp) +{ +ARM64SysRegField *field = (ARM64SysRegField *)opaque; +ARMCPU *cpu =ARM_CPU (obj); +uint64_t *idregs = cpu->isar.idregs; +uint64_t value, mask; +int lower = field->shift; +int length = field->length; +int index = field->index; + + mask =MAKE_64BIT_MASK (lower, length); + value = (idregs[index] & mask) >> lower; +visit_type_uint64 (v, name, &value, errp); +trace_get_sysreg_prop (name, value); +} + +static int +aarch64_add_idreg_properties (Object *obj,ARM64SysReg *reg) +{ +int nb_sysreg_props =0 ; + +for (int i =0 ; i < reg->fields_count; i++) { +ARM64SysRegField *field = ®->fields[i]; +char *prop_name =g_strdup_printf ("SYSREG_%s_%s" , reg->name, + field->name); +object_property_add (obj, prop_name,"uint64" , + get_sysreg_prop, set_sysreg_prop,NULL , field); +g_free (prop_name); + nb_sysreg_props++; + } + +trace_nb_sysreg_props (reg->name, nb_sysreg_props); +return 0 ; +} + +void aarch64_add_idregs_properties (Object *obj) +{ +for (int i =0 ; i <NUM_ID_IDX ; i++) { +ARM64SysReg *reg = &arm64_id_regs[i]; +aarch64_add_idreg_properties (obj, reg); + } +} +#endif +void aarch64_add_pauth_properties (Object *obj) {ARMCPU *cpu =ARM_CPU (obj);
@@ -865,8 +973,12 @@ static void aarch64_host_initfn(Object *obj)kvm_arm_set_cpu_features_from_host (cpu);aarch64_add_sve_properties (obj); -/* generate SYSREG properties according to writable masks */ -kvm_arm_expose_idreg_properties (cpu, arm64_id_regs); +#ifndef CONFIG_USER_ONLY +/* generate SYSREG properties */ +if (kvm_enabled ()) { +aarch64_add_idregs_properties (obj); + } +#endif #elif defined(CONFIG_HVF )hvf_arm_set_cpu_features_from_host (cpu);
target/arm/internals.h +3 -0
@@ -1754,6 +1754,9 @@ void aarch64_max_tcg_initfn(Object *obj);void aarch64_add_pauth_properties (Object *obj);void aarch64_add_sve_properties (Object *obj);void aarch64_add_sme_properties (Object *obj); +#ifndef CONFIG_USER_ONLY +void aarch64_add_idregs_properties (Object *obj); +#endif /* Return true if the gdbstub is presenting an AArch64 CPU */ static inline bool arm_gdbstub_is_aarch64 (ARMCPU *cpu)
target/arm/kvm.c +0 -151
157 lines not on this page · raw message
target/arm/kvm_arm.h +0 -8
@@ -143,14 +143,6 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu);void kvm_arm_add_vcpu_properties (ARMCPU *cpu);typedef struct ARM64SysReg ARM64SysReg ; -/** -* kvm_arm_expose_idreg_properties: -* @cpu: The CPU object to generate the properties for -* @reg: registers from the host -* -* analyze the writable mask and generate properties for writable fields -*/ -void kvm_arm_expose_idreg_properties (ARMCPU *cpu,ARM64SysReg *regs);/** * kvm_arm_steal_time_finalize:
target/arm/trace-events +2 -2
@@ -15,11 +15,11 @@ arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d" kvm_arm_fixup_msi_route(uint64_t iova, uint64_t gpa) "MSI iova = 0x%"PRIx64" is translated into 0x%"PRIx64 get_host_cpu_idregs(const char *name, uint64_t value) "scratch vcpu host value for %s is 0x%"PRIx64 kvm_arm_writable_idregs_to_cpreg_list(const char *name, uint64_t previous, uint64_t new) "%s overwrite default 0x%"PRIx64" with 0x%"PRIx64 -decode_idreg_writemap(const char* name, int lower, int upper, char *prop_name) "%s [%d:%d] is writable (prop %s)" + +# cpu64.c get_sysreg_prop(const char *name, uint64_t value) "%s 0x%"PRIx64 set_sysreg_prop(const char *name, uint64_t old, uint64_t mask, uint64_t field_value, uint64_t new) "%s old reg value=0x%"PRIx64" mask=0x%"PRIx64" new field value=0x%"PRIx64" new reg value=0x%"PRIx64 nb_sysreg_props(const char *name, int count) "%s: %d SYSREG properties" -unexpected_writable_reserved_field(const char *reg_name, const char *field_name, int lower, int upper) "Unexpected writable reserved field: %s.%s [%d,%d], skip it ..." # cpu.c arm_cpu_reset(uint64_t mp_aff) "cpu %" PRIu64
Signature · 1 line
2.52.0
Re: [RFC PATCH v3 04/19] target/arm: expose all ID regs fields as properties
Hi Khushit,
Quoted 6 lines · Khushit Shah
Upcoming named cpu models layer requires exposing all the ID register fields as properties.
While doing so also move the code to
cpu64.cto make it accelerator-agnostic, and rename the function toaarch64_add_idregs_properties().
Better to split that patch into 2 to ease the review:
1) update the code in kvm to expose all ID regs including those which are not writable and adaptation in set_sysreg_prop to handle RAZ, RES0/1, ...
2) Move to cpu64.c
To me it is still arguable whether it makes sense to expose settings which cannot be really set. To me It pollutes the qmp introspection output and I don't know whether there is any case history.
Why can't we:
- only expose writable id regs as props
- other non writable settings you need to check could be registered in a hash table during named cpu model definition in props.
in arm_apply_model_props() when you enumerate all props you can check if there is an existing prop for this name, in which case you really call
object_property_set_bool(), otherwise, you go through another path, which is not visible by the end user where you check the KVM value matches your "prop" value. No need to pretend this is writable. Also I am doubtful about RES/RAZ.
+ MODEL_PROP("SYSREG_CTR_EL0_RES1_31", NUM, 1),
does not make sense to me
Why can't you enumate all ID regs and go through those fields and check the KVM value matches. Why would we need to explicitly set a RAS/RES0/1 field. Why can't that be checked transparently. Thanks
Eric
Quoted 366 lines
This makes porting this solution to other accelerators easy in future.
Signed-off-by Khushit Shah <[email protected]>--- target/arm/cpu64.c | 116 +++++++++++++++++++++++++++++- target/arm/internals.h | 3 + target/arm/kvm.c | 151 ---------------------------------------- target/arm/kvm_arm.h | 8 --- target/arm/trace-events | 4 +- 5 files changed, 119 insertions(+), 163 deletions(-)target/arm/cpu64.c +114
-2@@ -38,6 +38,7 @@#include "internals.h" #include "cpu-features.h" #include "cpu-idregs.h" +#include "trace.h" /* convert between <register>_IDX and SYS_<register> */ #define DEF (NAME ,OP0 ,OP1 ,CRN ,CRM ,OP2 ) \@@ -644,6 +645,113 @@ static const Property arm_cpu_pauth_qarma3_property =static Property arm_cpu_pauth_qarma5_property =DEFINE_PROP_BOOL ("pauth-qarma5" ,ARMCPU , prop_pauth_qarma5, false); +#ifndef CONFIG_USER_ONLY +static void set_sysreg_prop (Object *obj,Visitor *v, +const char *name,void *opaque, +Error **errp) +{ +ARM64SysRegField *field = (ARM64SysRegField *)opaque; +ARMCPU *cpu =ARM_CPU (obj); +uint64_t *idregs = cpu->isar.idregs; +uint64_t old, value, mask; +int lower = field->shift; +int length = field->length; +int index = field->index; + +if (!visit_type_uint64 (v, name, &value, errp)) { +return ; + } + +if (length <64 && value > ((1ULL << length) -1 )) { +error_setg (errp, +"idreg %s set value (0x%lx) exceeds length of field (%d)!" , + name, value, length); +return ; + } + +if (field->arch_vals) { +/* this field has some enum values */ +for (int i =0 ; i < field->arch_vals_count; i++) { +if (value == field->arch_vals[i].value) { + goto valid; + } + } +error_setg (errp, +"idreg %s set value (0x%lx) does not match any " +"arch valid enum value!" , name, value); +return ; + } + +/* If the field is RESx or RAZ, it should not be written anything else */ +if (strstr (field->name,"RES0" ) && value !=0 ) { +error_setg (errp,"idreg %s is RES0 field and cannot write %ld" , + name, value); +return ; + }else if (strstr (field->name,"RAZ" ) && value !=0 ) { +error_setg (errp,"idreg %s is RAZ field and cannot write %ld" , + name, value); +return ; + }else if (strstr (field->name,"RES1" ) && value !=1 ) { +error_setg (errp,"idreg %s is RES1 field and cannot write %ld" , + name, value); +return ; + } + +valid: + mask =MAKE_64BIT_MASK (lower, length); + value = value << lower; + old = idregs[index]; + idregs[index] = old & ~mask; + idregs[index] |= value; +trace_set_sysreg_prop (name, old, mask, value, idregs[index]); +} + +static void get_sysreg_prop (Object *obj,Visitor *v, +const char *name,void *opaque, +Error **errp) +{ +ARM64SysRegField *field = (ARM64SysRegField *)opaque; +ARMCPU *cpu =ARM_CPU (obj); +uint64_t *idregs = cpu->isar.idregs; +uint64_t value, mask; +int lower = field->shift; +int length = field->length; +int index = field->index; + + mask =MAKE_64BIT_MASK (lower, length); + value = (idregs[index] & mask) >> lower; +visit_type_uint64 (v, name, &value, errp); +trace_get_sysreg_prop (name, value); +} + +static int +aarch64_add_idreg_properties (Object *obj,ARM64SysReg *reg) +{ +int nb_sysreg_props =0 ; + +for (int i =0 ; i < reg->fields_count; i++) { +ARM64SysRegField *field = ®->fields[i]; +char *prop_name =g_strdup_printf ("SYSREG_%s_%s" , reg->name, + field->name); +object_property_add (obj, prop_name,"uint64" , + get_sysreg_prop, set_sysreg_prop,NULL , field); +g_free (prop_name); + nb_sysreg_props++; + } + +trace_nb_sysreg_props (reg->name, nb_sysreg_props); +return 0 ; +} + +void aarch64_add_idregs_properties (Object *obj) +{ +for (int i =0 ; i <NUM_ID_IDX ; i++) { +ARM64SysReg *reg = &arm64_id_regs[i]; +aarch64_add_idreg_properties (obj, reg); + } +} +#endif +void aarch64_add_pauth_properties (Object *obj) {ARMCPU *cpu =ARM_CPU (obj);@@ -865,8 +973,12 @@ static void aarch64_host_initfn(Object *obj)kvm_arm_set_cpu_features_from_host (cpu);aarch64_add_sve_properties (obj); -/* generate SYSREG properties according to writable masks */ -kvm_arm_expose_idreg_properties (cpu, arm64_id_regs); +#ifndef CONFIG_USER_ONLY +/* generate SYSREG properties */ +if (kvm_enabled ()) { +aarch64_add_idregs_properties (obj); + } +#endif #elif defined(CONFIG_HVF )hvf_arm_set_cpu_features_from_host (cpu);target/arm/internals.h +3
-0@@ -1754,6 +1754,9 @@ void aarch64_max_tcg_initfn(Object *obj);void aarch64_add_pauth_properties (Object *obj);void aarch64_add_sve_properties (Object *obj);void aarch64_add_sme_properties (Object *obj); +#ifndef CONFIG_USER_ONLY +void aarch64_add_idregs_properties (Object *obj); +#endif /* Return true if the gdbstub is presenting an AArch64 CPU */ static inline bool arm_gdbstub_is_aarch64 (ARMCPU *cpu)target/arm/kvm.c +0
-151@@ -327,157 +327,6 @@ static int get_host_cpu_idregs(ARMCPU *cpu, int fd, ARMHostCPUFeatures *ahcf)return err; } -static ARM64SysRegField *get_field (int i,ARM64SysReg *reg) -{ -for (int f =0 ; f < reg->fields_count; f++) { -struct ARM64SysRegField *field = ®->fields[f]; -int upper = field->shift + field->length -1 ; - -if (i >= field->shift && i <= upper) { -return field; - } - } -return NULL ; -} - -static void set_sysreg_prop (Object *obj,Visitor *v, -const char *name,void *opaque, -Error **errp) -{ -ARM64SysRegField *field = (ARM64SysRegField *)opaque; -ARMCPU *cpu =ARM_CPU (obj); -uint64_t *idregs = cpu->isar.idregs; -uint64_t old, value, mask; -int lower = field->shift; -int length = field->length; -int index = field->index; - -if (!visit_type_uint64 (v, name, &value, errp)) { -return ; - } - -if (length <64 && value > ((1 << length) -1 )) { -error_setg (errp, -"idreg %s set value (0x%lx) exceeds length of field (%d)!" , - name, value, length); -return ; - } - -if (field->arch_vals) { -/* this field has some enum values */ -for (int i =0 ; i < field->arch_vals_count; i++) { -if (value == field->arch_vals[i].value) { - goto valid; - } - } -error_setg (errp, -"idreg %s set value (0x%lx) does not match any " -"arch valid enum value!" , name, value); -return ; - } - -valid: - - mask =MAKE_64BIT_MASK (lower, length); - value = value << lower; - old = idregs[index]; - idregs[index] = old & ~mask; - idregs[index] |= value; -trace_set_sysreg_prop (name, old, mask, value, idregs[index]); -} - -static void get_sysreg_prop (Object *obj,Visitor *v, -const char *name,void *opaque, -Error **errp) -{ -ARM64SysRegField *field = (ARM64SysRegField *)opaque; -ARMCPU *cpu =ARM_CPU (obj); -uint64_t *idregs = cpu->isar.idregs; -uint64_t value, mask; -int lower = field->shift; -int length = field->length; -int index = field->index; - - mask =MAKE_64BIT_MASK (lower, length); - value = (idregs[index] & mask) >> lower; -visit_type_uint64 (v, name, &value, errp); -trace_get_sysreg_prop (name, value); -} - -/* -* decode_idreg_writemap: Generate props for writable fields -* -* @obj: CPU object -* @reg: description of the sysreg -*/ -static int -decode_idreg_writemap (Object *obj,ARM64SysReg *reg) -{ -uint64_t map = reg->writable_mask; -int i =ctz64 (map); -int nb_sysreg_props =0 ; - -while (map) { -ARM64SysRegField *field =get_field (i, reg); -int lower, upper; -char *prop_name; -uint64_t field_mask; - -if (!field) { -warn_report ("%s bit %d of %s is writable but no named field " -"in target/arm/cpu-idregs.h.inc" , - __func__, i, reg->name); -warn_report ("%s is target/arm/cpu-idregs.h.inc up-to-date?" , __func__); - map = map & ~BIT_ULL (i); - i =ctz64 (map); -continue ; - } - lower = field->shift; - upper = field->shift + field->length -1 ; - -/* Sanity check the field is not a reserved field */ -if (strstr (field->name,"RES0" ) ||strstr (field->name,"RES1" ) || -strstr (field->name,"RAZ" )) { -trace_unexpected_writable_reserved_field (reg->name, field->name, - lower, upper); -continue ; - } - prop_name =g_strdup_printf ("SYSREG_%s_%s" , reg->name, field->name); -trace_decode_idreg_writemap (field->name, lower, upper, prop_name); -object_property_add (obj, prop_name,"uint64" , - get_sysreg_prop, set_sysreg_prop,NULL , field); -g_free (prop_name); - nb_sysreg_props++; - - field_mask =MAKE_64BIT_MASK (lower, field->length); - map = map & ~field_mask; - i =ctz64 (map); - } -trace_nb_sysreg_props (reg->name, nb_sysreg_props); -return 0 ; -} - -/* analyze the writable mask and generate properties for writable fields */ -void kvm_arm_expose_idreg_properties (ARMCPU *cpu,ARM64SysReg *regs) -{ -Object *obj =OBJECT (cpu); - -for (int i =0 ; i <NUM_ID_IDX ; i++) { -ARM64SysReg *sysregdesc = ®s[i]; - -if (sysregdesc->writable_mask) { -/* -* special case REVIDR_EL1 and AIDR_EL1 which are writable but -* do not expose named fields. They will need to be handled -* separately -*/ -if (strcmp (sysregdesc->name,"REVIDR_EL1" ) && -strcmp (sysregdesc->name,"AIDR_EL1" )) { -decode_idreg_writemap (obj, sysregdesc); - } - } - } -}static void kvm_arm_get_host_cpu_features (ARMCPU *cpu,ARMHostCPUFeatures *ahcf)target/arm/kvm_arm.h +0
-8@@ -143,14 +143,6 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu);void kvm_arm_add_vcpu_properties (ARMCPU *cpu);typedef struct ARM64SysReg ARM64SysReg ; -/** -* kvm_arm_expose_idreg_properties: -* @cpu: The CPU object to generate the properties for -* @reg: registers from the host -* -* analyze the writable mask and generate properties for writable fields -*/ -void kvm_arm_expose_idreg_properties (ARMCPU *cpu,ARM64SysReg *regs);/** * kvm_arm_steal_time_finalize: target/arm/trace-events +2
-2@@ -15,11 +15,11 @@ arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d" kvm_arm_fixup_msi_route(uint64_t iova, uint64_t gpa) "MSI iova = 0x%"PRIx64" is translated into 0x%"PRIx64 get_host_cpu_idregs(const char *name, uint64_t value) "scratch vcpu host value for %s is 0x%"PRIx64 kvm_arm_writable_idregs_to_cpreg_list(const char *name, uint64_t previous, uint64_t new) "%s overwrite default 0x%"PRIx64" with 0x%"PRIx64 -decode_idreg_writemap(const char* name, int lower, int upper, char *prop_name) "%s [%d:%d] is writable (prop %s)" + +# cpu64.c get_sysreg_prop(const char *name, uint64_t value) "%s 0x%"PRIx64 set_sysreg_prop(const char *name, uint64_t old, uint64_t mask, uint64_t field_value, uint64_t new) "%s old reg value=0x%"PRIx64" mask=0x%"PRIx64" new field value=0x%"PRIx64" new reg value=0x%"PRIx64 nb_sysreg_props(const char *name, int count) "%s: %d SYSREG properties" -unexpected_writable_reserved_field(const char *reg_name, const char *field_name, int lower, int upper) "Unexpected writable reserved field: %s.%s [%d,%d], skip it ..." # cpu.c arm_cpu_reset(uint64_t mp_aff) "cpu %" PRIu64
Re: [RFC PATCH v3 04/19] target/arm: expose all ID regs fields as properties
Quoted 19 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Hi Khushit,
Quoted 6 lines · Khushit Shah
Upcoming named cpu models layer requires exposing all the ID register fields as properties.
While doing so also move the code to
cpu64.cto make it accelerator-agnostic, and rename the function toaarch64_add_idregs_properties().
Quoted 5 lines
Better to split that patch into 2 to ease the review:
1) update the code in kvm to expose all ID regs including those which are not writable and adaptation inset_sysreg_propto handle RAZ, RES0/1, ...
2) Move tocpu64.c
This makes more sense, thanks, will do that in v4.
Quoted 11 lines
To me it is still arguable whether it makes sense to expose settings which cannot be really set. To me It pollutes the qmp introspection output and I don't know whether there is any case history. Why can't we:
- only expose writable id regs as props
- other non writable settings you need to check could be registered in a hash table during named cpu model definition in props.
inarm_apply_model_props()when you enumerate all props you can check if there is an existing prop for this name, in which case you really call
object_property_set_bool(), otherwise, you go through another path, which is not visible by the end user where you check the KVM value matches your "prop" value. No need to pretend this is writable.
Please refer to my below text.
Quoted 7 lines
Also I am doubtful about RES/RAZ.
+
MODEL_PROP("SYSREG_CTR_EL0_RES1_31", NUM, 1),does not make sense to me
Why can't you enumate all ID regs and go through those fields and check the KVM value matches. Why would we need to explicitly set a RAS/RES0/1 field. Why can't that be checked transparently.
Why do we need non-writable field props?:
- Assume some non-writable field mismatches for the model and host, why do we want to stop users from explicitly overriding the model's field value to host value?
- Even with cpu -host, how will upper layer know, if they can migrate between host A and host B? (Without actually doing the migration)
-> Only if all non-writable fields in both host matches
and writable fields in both host are “compatible”.
Why would we need to explicitly set a RAS/RES0/1 field?
- Here my argument is a little weaker but, what if RES1 field is repurposed in the future? We still want existing models to show 1.
RES0 does not need any special handling, only RES1 field needs this special handling.
Does the above arguments make sense?
Warm Regards,
Khushit
Quoted 371 lines
Thanks
Eric
Quoted 366 lines
This makes porting this solution to other accelerators easy in future.
Signed-off-by Khushit Shah <[email protected]>---
target/arm/cpu64.c | 116 +++++++++++++++++++++++++++++- target/arm/internals.h | 3 + target/arm/kvm.c | 151 ---------------------------------------- target/arm/kvm_arm.h | 8 --- target/arm/trace-events | 4 +- 5 files changed, 119 insertions(+), 163 deletions(-)target/arm/cpu64.c +1
-0@@ -38,6 +38,7 @@#include "internals.h" #include "cpu-features.h" #include "cpu-idregs.h" +#include "trace.h" /* convert between <register>_IDX and SYS_<register> */ #define DEF (NAME ,OP0 ,OP1 ,CRN ,CRM ,OP2 ) \@@ -644,6 +645,113 @@ static const Property arm_cpu_pauth_qarma3_property =static Property
arm_cpu_pauth_qarma5_property=DEFINE_PROP_BOOL("pauth-qarma5", ARMCPU, prop_pauth_qarma5, false);target/arm/cpu64.c +107
-0+#ifndef CONFIG_USER_ONLY +static void set_sysreg_prop (Object *obj,Visitor *v, +const char *name,void *opaque, +Error **errp) +{ +ARM64SysRegField *field = (ARM64SysRegField *)opaque; +ARMCPU *cpu =ARM_CPU (obj); +uint64_t *idregs = cpu->isar.idregs; +uint64_t old, value, mask; +int lower = field->shift; +int length = field->length; +int index = field->index; + +if (!visit_type_uint64 (v, name, &value, errp)) { +return ; + } + +if (length <64 && value > ((1ULL << length) -1 )) { +error_setg (errp, +"idreg %s set value (0x%lx) exceeds length of field (%d)!" , + name, value, length); +return ; + } + +if (field->arch_vals) { +/* this field has some enum values */ +for (int i =0 ; i < field->arch_vals_count; i++) { +if (value == field->arch_vals[i].value) { + goto valid; + } + } +error_setg (errp, +"idreg %s set value (0x%lx) does not match any " +"arch valid enum value!" , name, value); +return ; + } + +/* If the field is RESx or RAZ, it should not be written anything else */ +if (strstr (field->name,"RES0" ) && value !=0 ) { +error_setg (errp,"idreg %s is RES0 field and cannot write %ld" , + name, value); +return ; + }else if (strstr (field->name,"RAZ" ) && value !=0 ) { +error_setg (errp,"idreg %s is RAZ field and cannot write %ld" , + name, value); +return ; + }else if (strstr (field->name,"RES1" ) && value !=1 ) { +error_setg (errp,"idreg %s is RES1 field and cannot write %ld" , + name, value); +return ; + } + +valid: + mask =MAKE_64BIT_MASK (lower, length); + value = value << lower; + old = idregs[index]; + idregs[index] = old & ~mask; + idregs[index] |= value; +trace_set_sysreg_prop (name, old, mask, value, idregs[index]); +} + +static void get_sysreg_prop (Object *obj,Visitor *v, +const char *name,void *opaque, +Error **errp) +{ +ARM64SysRegField *field = (ARM64SysRegField *)opaque; +ARMCPU *cpu =ARM_CPU (obj); +uint64_t *idregs = cpu->isar.idregs; +uint64_t value, mask; +int lower = field->shift; +int length = field->length; +int index = field->index; + + mask =MAKE_64BIT_MASK (lower, length); + value = (idregs[index] & mask) >> lower; +visit_type_uint64 (v, name, &value, errp); +trace_get_sysreg_prop (name, value); +} + +static int +aarch64_add_idreg_properties (Object *obj,ARM64SysReg *reg) +{ +int nb_sysreg_props =0 ; + +for (int i =0 ; i < reg->fields_count; i++) { +ARM64SysRegField *field = ®->fields[i]; +char *prop_name =g_strdup_printf ("SYSREG_%s_%s" , reg->name, + field->name); +object_property_add (obj, prop_name,"uint64" , + get_sysreg_prop, set_sysreg_prop,NULL , field); +g_free (prop_name); + nb_sysreg_props++; + } + +trace_nb_sysreg_props (reg->name, nb_sysreg_props); +return 0 ; +} + +void aarch64_add_idregs_properties (Object *obj) +{ +for (int i =0 ; i <NUM_ID_IDX ; i++) { +ARM64SysReg *reg = &arm64_id_regs[i]; +aarch64_add_idreg_properties (obj, reg); + } +} +#endif +void
aarch64_add_pauth_properties(Object *obj){ ARMCPU *cpu = ARM_CPU(obj);target/arm/cpu64.c +6
-2@@ -865,8 +973,12 @@ static void aarch64_host_initfn(Object *obj)kvm_arm_set_cpu_features_from_host (cpu);aarch64_add_sve_properties (obj); -/* generate SYSREG properties according to writable masks */ -kvm_arm_expose_idreg_properties (cpu, arm64_id_regs); +#ifndef CONFIG_USER_ONLY +/* generate SYSREG properties */ +if (kvm_enabled ()) { +aarch64_add_idregs_properties (obj); + } +#endif #elif defined(CONFIG_HVF )hvf_arm_set_cpu_features_from_host (cpu);target/arm/internals.h +3
-0@@ -1754,6 +1754,9 @@ void aarch64_max_tcg_initfn(Object *obj);void aarch64_add_pauth_properties (Object *obj);void aarch64_add_sve_properties (Object *obj);void aarch64_add_sme_properties (Object *obj); +#ifndef CONFIG_USER_ONLY +void aarch64_add_idregs_properties (Object *obj); +#endif /* Return true if the gdbstub is presenting an AArch64 CPU */ static inline bool arm_gdbstub_is_aarch64 (ARMCPU *cpu)target/arm/kvm.c +0
-151@@ -327,157 +327,6 @@ static int get_host_cpu_idregs(ARMCPU *cpu, int fd, ARMHostCPUFeatures *ahcf)return err; } -static ARM64SysRegField *get_field (int i,ARM64SysReg *reg) -{ -for (int f =0 ; f < reg->fields_count; f++) { -struct ARM64SysRegField *field = ®->fields[f]; -int upper = field->shift + field->length -1 ; - -if (i >= field->shift && i <= upper) { -return field; - } - } -return NULL ; -} - -static void set_sysreg_prop (Object *obj,Visitor *v, -const char *name,void *opaque, -Error **errp) -{ -ARM64SysRegField *field = (ARM64SysRegField *)opaque; -ARMCPU *cpu =ARM_CPU (obj); -uint64_t *idregs = cpu->isar.idregs; -uint64_t old, value, mask; -int lower = field->shift; -int length = field->length; -int index = field->index; - -if (!visit_type_uint64 (v, name, &value, errp)) { -return ; - } - -if (length <64 && value > ((1 << length) -1 )) { -error_setg (errp, -"idreg %s set value (0x%lx) exceeds length of field (%d)!" , - name, value, length); -return ; - } - -if (field->arch_vals) { -/* this field has some enum values */ -for (int i =0 ; i < field->arch_vals_count; i++) { -if (value == field->arch_vals[i].value) { - goto valid; - } - } -error_setg (errp, -"idreg %s set value (0x%lx) does not match any " -"arch valid enum value!" , name, value); -return ; - } - -valid: - - mask =MAKE_64BIT_MASK (lower, length); - value = value << lower; - old = idregs[index]; - idregs[index] = old & ~mask; - idregs[index] |= value; -trace_set_sysreg_prop (name, old, mask, value, idregs[index]); -} - -static void get_sysreg_prop (Object *obj,Visitor *v, -const char *name,void *opaque, -Error **errp) -{ -ARM64SysRegField *field = (ARM64SysRegField *)opaque; -ARMCPU *cpu =ARM_CPU (obj); -uint64_t *idregs = cpu->isar.idregs; -uint64_t value, mask; -int lower = field->shift; -int length = field->length; -int index = field->index; - - mask =MAKE_64BIT_MASK (lower, length); - value = (idregs[index] & mask) >> lower; -visit_type_uint64 (v, name, &value, errp); -trace_get_sysreg_prop (name, value); -} - -/* -* decode_idreg_writemap: Generate props for writable fields -* -* @obj: CPU object -* @reg: description of the sysreg -*/ -static int -decode_idreg_writemap (Object *obj,ARM64SysReg *reg) -{ -uint64_t map = reg->writable_mask; -int i =ctz64 (map); -int nb_sysreg_props =0 ; - -while (map) { -ARM64SysRegField *field =get_field (i, reg); -int lower, upper; -char *prop_name; -uint64_t field_mask; - -if (!field) { -warn_report ("%s bit %d of %s is writable but no named field " -"in target/arm/cpu-idregs.h.inc" , - __func__, i, reg->name); -warn_report ("%s is target/arm/cpu-idregs.h.inc up-to-date?" , __func__); - map = map & ~BIT_ULL (i); - i =ctz64 (map); -continue ; - } - lower = field->shift; - upper = field->shift + field->length -1 ; - -/* Sanity check the field is not a reserved field */ -if (strstr (field->name,"RES0" ) ||strstr (field->name,"RES1" ) || -strstr (field->name,"RAZ" )) { -trace_unexpected_writable_reserved_field (reg->name, field->name, - lower, upper); -continue ; - } - prop_name =g_strdup_printf ("SYSREG_%s_%s" , reg->name, field->name); -trace_decode_idreg_writemap (field->name, lower, upper, prop_name); -object_property_add (obj, prop_name,"uint64" , - get_sysreg_prop, set_sysreg_prop,NULL , field); -g_free (prop_name); - nb_sysreg_props++; - - field_mask =MAKE_64BIT_MASK (lower, field->length); - map = map & ~field_mask; - i =ctz64 (map); - } -trace_nb_sysreg_props (reg->name, nb_sysreg_props); -return 0 ; -} - -/* analyze the writable mask and generate properties for writable fields */ -void kvm_arm_expose_idreg_properties (ARMCPU *cpu,ARM64SysReg *regs) -{ -Object *obj =OBJECT (cpu); - -for (int i =0 ; i <NUM_ID_IDX ; i++) { -ARM64SysReg *sysregdesc = ®s[i]; - -if (sysregdesc->writable_mask) { -/* -* special case REVIDR_EL1 and AIDR_EL1 which are writable but -* do not expose named fields. They will need to be handled -* separately -*/ -if (strcmp (sysregdesc->name,"REVIDR_EL1" ) && -strcmp (sysregdesc->name,"AIDR_EL1" )) { -decode_idreg_writemap (obj, sysregdesc); - } - } - } -}static void
kvm_arm_get_host_cpu_features(ARMCPU *cpu, ARMHostCPUFeatures *ahcf)target/arm/kvm_arm.h +0
-8@@ -143,14 +143,6 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu);void kvm_arm_add_vcpu_properties (ARMCPU *cpu);typedef struct ARM64SysReg ARM64SysReg ; -/** -* kvm_arm_expose_idreg_properties: -* @cpu: The CPU object to generate the properties for -* @reg: registers from the host -* -* analyze the writable mask and generate properties for writable fields -*/ -void kvm_arm_expose_idreg_properties (ARMCPU *cpu,ARM64SysReg *regs);/** * kvm_arm_steal_time_finalize: target/arm/trace-events +0
-0@@ -15,11 +15,11 @@ arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d"
kvm_arm_fixup_msi_route(uint64_t iova, uint64_t gpa)"MSI iova = 0x%"PRIx64" is translated into 0x%"PRIx64get_host_cpu_idregs(const char *name, uint64_t value)"scratch vcpu host value for %s is 0x%"PRIx64kvm_arm_writable_idregs_to_cpreg_list(const char *name, uint64_t previous, uint64_t new)"%s overwrite default 0x%"PRIx64" with 0x%"PRIx64target/arm/trace-events +2
-1-decode_idreg_writemap(const char* name, int lower, int upper, char *prop_name) "%s [%d:%d] is writable (prop %s)" + +# cpu64.c
get_sysreg_prop(const char *name, uint64_t value)"%s 0x%"PRIx64set_sysreg_prop(const char *name, uint64_t old, uint64_t mask, uint64_t field_value, uint64_t new)"%s old reg value=0x%"PRIx64" mask=0x%"PRIx64" new field value=0x%"PRIx64" new reg value=0x%"PRIx64nb_sysreg_props(const char *name, int count)"%s: %d SYSREG properties"
-unexpected_writable_reserved_field(const char*reg_name, const char*field_name, int lower, int upper) "Unexpected writable reserved field: %s.%s [%d,%d], skip it ..."# cpu.c arm_cpu_reset(uint64_t mp_aff) "cpu %" PRIu64
Re: [RFC PATCH v3 04/19] target/arm: expose all ID regs fields as properties
Quoted 44 lines · Khushit Shah
Quoted 14 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Hi Khushit,
Quoted 3 lines · Khushit Shah
Upcoming named cpu models layer requires exposing all the ID register fields as properties.
Quoted 8 lines
Quoted 3 lines
While doing so also move the code to
cpu64.cto make it accelerator-agnostic, and rename the function toaarch64_add_idregs_properties().Better to split that patch into 2 to ease the review:
1) update the code in kvm to expose all ID regs including those which are not writable and adaptation inset_sysreg_propto handle RAZ, RES0/1, ...
2) Move tocpu64.cThis makes more sense, thanks, will do that in v4.
Quoted 11 lines
To me it is still arguable whether it makes sense to expose settings which cannot be really set. To me It pollutes the qmp introspection output and I don't know whether there is any case history. Why can't we:
- only expose writable id regs as props
- other non writable settings you need to check could be registered in a hash table during named cpu model definition in props.
inarm_apply_model_props()when you enumerate all props you can check if there is an existing prop for this name, in which case you really call
object_property_set_bool(), otherwise, you go through another path, which is not visible by the end user where you check the KVM value matches your "prop" value. No need to pretend this is writable.Please refer to my below text.
Quoted 7 lines
Also I am doubtful about RES/RAZ.
+
MODEL_PROP("SYSREG_CTR_EL0_RES1_31", NUM, 1),does not make sense to me
Why can't you enumate all ID regs and go through those fields and check the KVM value matches. Why would we need to explicitly set a RAS/RES0/1 field. Why can't that be checked transparently.
Quoted 9 lines
Why do we need non-writable field props?:
- Assume some non-writable field mismatches for the model and host, why do we want to stop users from explicitly overriding the model's field value to host value?
- Even with cpu -host, how will upper layer know, if they can migrate between host A and host B? (Without actually doing the migration)
-> Only if all non-writable fields in both host matches
and writable fields in both host are “compatible”.
I do agree with you we need to check non writable fields do match. What I am challenging is the fact you want to expose non writable idregs through qemu properties. If it is not writable why would we pretend the end user can change it through the cmd line. You can set the expected field value in the vcpu model description through DEFINEs or whatever method. Then on init, the model will read the host value and fails the init if they don't match. The fact no prop is available for this field would teach the end user the field is not writable.
The above MODEL_PROP() could be a wrapper that either sets the actual property if it exists (for a writable field) or just silently populate a table of expected non writable field values that are checked on init, no?
Quoted 5 lines
Why would we need to explicitly set a RAS/RES0/1 field?
- Here my argument is a little weaker but, what if RES1 field is repurposed in the future? We still want existing models to show 1.
AARCHMRS description tells you which fields are RESx. You can read the host value and fails the init in case of mismatch.
Thanks
Eric
Quoted 378 lines
RES0 does not need any special handling, only RES1 field needs this special handling.
Does the above arguments make sense?
Warm Regards,
KhushitQuoted 369 lines
Thanks
Eric
Quoted 365 lines
This makes porting this solution to other accelerators easy in future.
Signed-off-by Khushit Shah <[email protected]>---
target/arm/cpu64.c | 116 +++++++++++++++++++++++++++++- target/arm/internals.h | 3 + target/arm/kvm.c | 151 ---------------------------------------- target/arm/kvm_arm.h | 8 --- target/arm/trace-events | 4 +- 5 files changed, 119 insertions(+), 163 deletions(-)target/arm/cpu64.c +1
-0@@ -38,6 +38,7 @@#include "internals.h" #include "cpu-features.h" #include "cpu-idregs.h" +#include "trace.h" /* convert between <register>_IDX and SYS_<register> */ #define DEF (NAME ,OP0 ,OP1 ,CRN ,CRM ,OP2 ) \@@ -644,6 +645,113 @@ static const Property arm_cpu_pauth_qarma3_property =static Property
arm_cpu_pauth_qarma5_property=DEFINE_PROP_BOOL("pauth-qarma5", ARMCPU, prop_pauth_qarma5, false);target/arm/cpu64.c +107
-0+#ifndef CONFIG_USER_ONLY +static void set_sysreg_prop (Object *obj,Visitor *v, +const char *name,void *opaque, +Error **errp) +{ +ARM64SysRegField *field = (ARM64SysRegField *)opaque; +ARMCPU *cpu =ARM_CPU (obj); +uint64_t *idregs = cpu->isar.idregs; +uint64_t old, value, mask; +int lower = field->shift; +int length = field->length; +int index = field->index; + +if (!visit_type_uint64 (v, name, &value, errp)) { +return ; + } + +if (length <64 && value > ((1ULL << length) -1 )) { +error_setg (errp, +"idreg %s set value (0x%lx) exceeds length of field (%d)!" , + name, value, length); +return ; + } + +if (field->arch_vals) { +/* this field has some enum values */ +for (int i =0 ; i < field->arch_vals_count; i++) { +if (value == field->arch_vals[i].value) { + goto valid; + } + } +error_setg (errp, +"idreg %s set value (0x%lx) does not match any " +"arch valid enum value!" , name, value); +return ; + } + +/* If the field is RESx or RAZ, it should not be written anything else */ +if (strstr (field->name,"RES0" ) && value !=0 ) { +error_setg (errp,"idreg %s is RES0 field and cannot write %ld" , + name, value); +return ; + }else if (strstr (field->name,"RAZ" ) && value !=0 ) { +error_setg (errp,"idreg %s is RAZ field and cannot write %ld" , + name, value); +return ; + }else if (strstr (field->name,"RES1" ) && value !=1 ) { +error_setg (errp,"idreg %s is RES1 field and cannot write %ld" , + name, value); +return ; + } + +valid: + mask =MAKE_64BIT_MASK (lower, length); + value = value << lower; + old = idregs[index]; + idregs[index] = old & ~mask; + idregs[index] |= value; +trace_set_sysreg_prop (name, old, mask, value, idregs[index]); +} + +static void get_sysreg_prop (Object *obj,Visitor *v, +const char *name,void *opaque, +Error **errp) +{ +ARM64SysRegField *field = (ARM64SysRegField *)opaque; +ARMCPU *cpu =ARM_CPU (obj); +uint64_t *idregs = cpu->isar.idregs; +uint64_t value, mask; +int lower = field->shift; +int length = field->length; +int index = field->index; + + mask =MAKE_64BIT_MASK (lower, length); + value = (idregs[index] & mask) >> lower; +visit_type_uint64 (v, name, &value, errp); +trace_get_sysreg_prop (name, value); +} + +static int +aarch64_add_idreg_properties (Object *obj,ARM64SysReg *reg) +{ +int nb_sysreg_props =0 ; + +for (int i =0 ; i < reg->fields_count; i++) { +ARM64SysRegField *field = ®->fields[i]; +char *prop_name =g_strdup_printf ("SYSREG_%s_%s" , reg->name, + field->name); +object_property_add (obj, prop_name,"uint64" , + get_sysreg_prop, set_sysreg_prop,NULL , field); +g_free (prop_name); + nb_sysreg_props++; + } + +trace_nb_sysreg_props (reg->name, nb_sysreg_props); +return 0 ; +} + +void aarch64_add_idregs_properties (Object *obj) +{ +for (int i =0 ; i <NUM_ID_IDX ; i++) { +ARM64SysReg *reg = &arm64_id_regs[i]; +aarch64_add_idreg_properties (obj, reg); + } +} +#endif +void
aarch64_add_pauth_properties(Object *obj){ ARMCPU *cpu = ARM_CPU(obj);target/arm/cpu64.c +6
-2@@ -865,8 +973,12 @@ static void aarch64_host_initfn(Object *obj)kvm_arm_set_cpu_features_from_host (cpu);aarch64_add_sve_properties (obj); -/* generate SYSREG properties according to writable masks */ -kvm_arm_expose_idreg_properties (cpu, arm64_id_regs); +#ifndef CONFIG_USER_ONLY +/* generate SYSREG properties */ +if (kvm_enabled ()) { +aarch64_add_idregs_properties (obj); + } +#endif #elif defined(CONFIG_HVF )hvf_arm_set_cpu_features_from_host (cpu);target/arm/internals.h +3
-0@@ -1754,6 +1754,9 @@ void aarch64_max_tcg_initfn(Object *obj);void aarch64_add_pauth_properties (Object *obj);void aarch64_add_sve_properties (Object *obj);void aarch64_add_sme_properties (Object *obj); +#ifndef CONFIG_USER_ONLY +void aarch64_add_idregs_properties (Object *obj); +#endif /* Return true if the gdbstub is presenting an AArch64 CPU */ static inline bool arm_gdbstub_is_aarch64 (ARMCPU *cpu)target/arm/kvm.c +0
-151@@ -327,157 +327,6 @@ static int get_host_cpu_idregs(ARMCPU *cpu, int fd, ARMHostCPUFeatures *ahcf)return err; } -static ARM64SysRegField *get_field (int i,ARM64SysReg *reg) -{ -for (int f =0 ; f < reg->fields_count; f++) { -struct ARM64SysRegField *field = ®->fields[f]; -int upper = field->shift + field->length -1 ; - -if (i >= field->shift && i <= upper) { -return field; - } - } -return NULL ; -} - -static void set_sysreg_prop (Object *obj,Visitor *v, -const char *name,void *opaque, -Error **errp) -{ -ARM64SysRegField *field = (ARM64SysRegField *)opaque; -ARMCPU *cpu =ARM_CPU (obj); -uint64_t *idregs = cpu->isar.idregs; -uint64_t old, value, mask; -int lower = field->shift; -int length = field->length; -int index = field->index; - -if (!visit_type_uint64 (v, name, &value, errp)) { -return ; - } - -if (length <64 && value > ((1 << length) -1 )) { -error_setg (errp, -"idreg %s set value (0x%lx) exceeds length of field (%d)!" , - name, value, length); -return ; - } - -if (field->arch_vals) { -/* this field has some enum values */ -for (int i =0 ; i < field->arch_vals_count; i++) { -if (value == field->arch_vals[i].value) { - goto valid; - } - } -error_setg (errp, -"idreg %s set value (0x%lx) does not match any " -"arch valid enum value!" , name, value); -return ; - } - -valid: - - mask =MAKE_64BIT_MASK (lower, length); - value = value << lower; - old = idregs[index]; - idregs[index] = old & ~mask; - idregs[index] |= value; -trace_set_sysreg_prop (name, old, mask, value, idregs[index]); -} - -static void get_sysreg_prop (Object *obj,Visitor *v, -const char *name,void *opaque, -Error **errp) -{ -ARM64SysRegField *field = (ARM64SysRegField *)opaque; -ARMCPU *cpu =ARM_CPU (obj); -uint64_t *idregs = cpu->isar.idregs; -uint64_t value, mask; -int lower = field->shift; -int length = field->length; -int index = field->index; - - mask =MAKE_64BIT_MASK (lower, length); - value = (idregs[index] & mask) >> lower; -visit_type_uint64 (v, name, &value, errp); -trace_get_sysreg_prop (name, value); -} - -/* -* decode_idreg_writemap: Generate props for writable fields -* -* @obj: CPU object -* @reg: description of the sysreg -*/ -static int -decode_idreg_writemap (Object *obj,ARM64SysReg *reg) -{ -uint64_t map = reg->writable_mask; -int i =ctz64 (map); -int nb_sysreg_props =0 ; - -while (map) { -ARM64SysRegField *field =get_field (i, reg); -int lower, upper; -char *prop_name; -uint64_t field_mask; - -if (!field) { -warn_report ("%s bit %d of %s is writable but no named field " -"in target/arm/cpu-idregs.h.inc" , - __func__, i, reg->name); -warn_report ("%s is target/arm/cpu-idregs.h.inc up-to-date?" , __func__); - map = map & ~BIT_ULL (i); - i =ctz64 (map); -continue ; - } - lower = field->shift; - upper = field->shift + field->length -1 ; - -/* Sanity check the field is not a reserved field */ -if (strstr (field->name,"RES0" ) ||strstr (field->name,"RES1" ) || -strstr (field->name,"RAZ" )) { -trace_unexpected_writable_reserved_field (reg->name, field->name, - lower, upper); -continue ; - } - prop_name =g_strdup_printf ("SYSREG_%s_%s" , reg->name, field->name); -trace_decode_idreg_writemap (field->name, lower, upper, prop_name); -object_property_add (obj, prop_name,"uint64" , - get_sysreg_prop, set_sysreg_prop,NULL , field); -g_free (prop_name); - nb_sysreg_props++; - - field_mask =MAKE_64BIT_MASK (lower, field->length); - map = map & ~field_mask; - i =ctz64 (map); - } -trace_nb_sysreg_props (reg->name, nb_sysreg_props); -return 0 ; -} - -/* analyze the writable mask and generate properties for writable fields */ -void kvm_arm_expose_idreg_properties (ARMCPU *cpu,ARM64SysReg *regs) -{ -Object *obj =OBJECT (cpu); - -for (int i =0 ; i <NUM_ID_IDX ; i++) { -ARM64SysReg *sysregdesc = ®s[i]; - -if (sysregdesc->writable_mask) { -/* -* special case REVIDR_EL1 and AIDR_EL1 which are writable but -* do not expose named fields. They will need to be handled -* separately -*/ -if (strcmp (sysregdesc->name,"REVIDR_EL1" ) && -strcmp (sysregdesc->name,"AIDR_EL1" )) { -decode_idreg_writemap (obj, sysregdesc); - } - } - } -}static void
kvm_arm_get_host_cpu_features(ARMCPU *cpu, ARMHostCPUFeatures *ahcf)target/arm/kvm_arm.h +0
-8@@ -143,14 +143,6 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu);void kvm_arm_add_vcpu_properties (ARMCPU *cpu);typedef struct ARM64SysReg ARM64SysReg ; -/** -* kvm_arm_expose_idreg_properties: -* @cpu: The CPU object to generate the properties for -* @reg: registers from the host -* -* analyze the writable mask and generate properties for writable fields -*/ -void kvm_arm_expose_idreg_properties (ARMCPU *cpu,ARM64SysReg *regs);/** * kvm_arm_steal_time_finalize: target/arm/trace-events +0
-0@@ -15,11 +15,11 @@ arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d"
kvm_arm_fixup_msi_route(uint64_t iova, uint64_t gpa)"MSI iova = 0x%"PRIx64" is translated into 0x%"PRIx64get_host_cpu_idregs(const char *name, uint64_t value)"scratch vcpu host value for %s is 0x%"PRIx64kvm_arm_writable_idregs_to_cpreg_list(const char *name, uint64_t previous, uint64_t new)"%s overwrite default 0x%"PRIx64" with 0x%"PRIx64target/arm/trace-events +2
-1-decode_idreg_writemap(const char* name, int lower, int upper, char *prop_name) "%s [%d:%d] is writable (prop %s)" + +# cpu64.c
get_sysreg_prop(const char *name, uint64_t value)"%s 0x%"PRIx64set_sysreg_prop(const char *name, uint64_t old, uint64_t mask, uint64_t field_value, uint64_t new)"%s old reg value=0x%"PRIx64" mask=0x%"PRIx64" new field value=0x%"PRIx64" new reg value=0x%"PRIx64nb_sysreg_props(const char *name, int count)"%s: %d SYSREG properties"
-unexpected_writable_reserved_field(const char*reg_name, const char*field_name, int lower, int upper) "Unexpected writable reserved field: %s.%s [%d,%d], skip it ..."# cpu.c arm_cpu_reset(uint64_t mp_aff) "cpu %" PRIu64
Re: [RFC PATCH v3 04/19] target/arm: expose all ID regs fields as properties
Quoted 75 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 44 lines · Khushit Shah
Quoted 14 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Hi Khushit,
Quoted 3 lines · Khushit Shah
Upcoming named cpu models layer requires exposing all the ID register fields as properties.
Quoted 8 lines
Quoted 3 lines
While doing so also move the code to
cpu64.cto make it accelerator-agnostic, and rename the function toaarch64_add_idregs_properties().Better to split that patch into 2 to ease the review:
1) update the code in kvm to expose all ID regs including those which are not writable and adaptation inset_sysreg_propto handle RAZ, RES0/1, ...
2) Move tocpu64.cThis makes more sense, thanks, will do that in v4.
Quoted 11 lines
To me it is still arguable whether it makes sense to expose settings which cannot be really set. To me It pollutes the qmp introspection output and I don't know whether there is any case history. Why can't we:
- only expose writable id regs as props
- other non writable settings you need to check could be registered in a hash table during named cpu model definition in props.
inarm_apply_model_props()when you enumerate all props you can check if there is an existing prop for this name, in which case you really call
object_property_set_bool(), otherwise, you go through another path, which is not visible by the end user where you check the KVM value matches your "prop" value. No need to pretend this is writable.Please refer to my below text.
Quoted 7 lines
Also I am doubtful about RES/RAZ.
+
MODEL_PROP("SYSREG_CTR_EL0_RES1_31", NUM, 1),does not make sense to me
Why can't you enumate all ID regs and go through those fields and check the KVM value matches. Why would we need to explicitly set a RAS/RES0/1 field. Why can't that be checked transparently.
Quoted 9 lines
Why do we need non-writable field props?:
- Assume some non-writable field mismatches for the model and host, why do we want to stop users from explicitly overriding the model's field value to host value?
- Even with cpu -host, how will upper layer know, if they can migrate between host A and host B? (Without actually doing the migration)
-> Only if all non-writable fields in both host matches
and writable fields in both host are “compatible”.I do agree with you we need to check non writable fields do match. What I am challenging is the fact you want to expose non writable idregs through qemu properties. If it is not writable why would we pretend the end user can change it through the cmd line. You can set the expected field value in the vcpu model description through DEFINEs or whatever method. Then on init, the model will read the host value and fails the init if they don't match. The fact no prop is available for this field would teach the end user the field is not writable.
Quoted 3 lines
The above
MODEL_PROP()could be a wrapper that either sets the actual property if it exists (for a writable field) or just silently populate a table of expected non writable field values that are checked on init, no?
Okay, I think here the confusion lies in perspective of writability.
From my perspective, a field is only host non-writable, i.e. every guest on host should have the same field value.
But this should not restrict model’s field writability. Take the “pauth” example as explained earlier. A field being non-writable does not mean we cannot change model’s value, it only means we cannot change host value, right?
Quoted 8 lines
Quoted 5 lines
Why would we need to explicitly set a RAS/RES0/1 field?
- Here my argument is a little weaker but, what if RES1 field is repurposed in the future? We still want existing models to show 1.AARCHMRS description tells you which fields are RESx. You can read the host value and fails the init in case of mismatch.
I agree, will remove RAS/RES props.
Warm Regards,
Khushit
Quoted 382 lines
Thanks
Eric
Quoted 378 lines
RES0 does not need any special handling, only RES1 field needs this special handling.
Does the above arguments make sense?
Warm Regards,
KhushitQuoted 369 lines
Thanks
Eric
Quoted 365 lines
This makes porting this solution to other accelerators easy in future.
Signed-off-by Khushit Shah <[email protected]>---
target/arm/cpu64.c | 116 +++++++++++++++++++++++++++++- target/arm/internals.h | 3 + target/arm/kvm.c | 151 ---------------------------------------- target/arm/kvm_arm.h | 8 --- target/arm/trace-events | 4 +- 5 files changed, 119 insertions(+), 163 deletions(-)target/arm/cpu64.c +1
-0@@ -38,6 +38,7 @@#include "internals.h" #include "cpu-features.h" #include "cpu-idregs.h" +#include "trace.h" /* convert between <register>_IDX and SYS_<register> */ #define DEF (NAME ,OP0 ,OP1 ,CRN ,CRM ,OP2 ) \@@ -644,6 +645,113 @@ static const Property arm_cpu_pauth_qarma3_property =static Property
arm_cpu_pauth_qarma5_property=
DEFINE_PROP_BOOL("pauth-qarma5", ARMCPU, prop_pauth_qarma5, false);target/arm/cpu64.c +107
-0+#ifndef CONFIG_USER_ONLY +static void set_sysreg_prop (Object *obj,Visitor *v, +const char *name,void *opaque, +Error **errp) +{ +ARM64SysRegField *field = (ARM64SysRegField *)opaque; +ARMCPU *cpu =ARM_CPU (obj); +uint64_t *idregs = cpu->isar.idregs; +uint64_t old, value, mask; +int lower = field->shift; +int length = field->length; +int index = field->index; + +if (!visit_type_uint64 (v, name, &value, errp)) { +return ; + } + +if (length <64 && value > ((1ULL << length) -1 )) { +error_setg (errp, +"idreg %s set value (0x%lx) exceeds length of field (%d)!" , + name, value, length); +return ; + } + +if (field->arch_vals) { +/* this field has some enum values */ +for (int i =0 ; i < field->arch_vals_count; i++) { +if (value == field->arch_vals[i].value) { + goto valid; + } + } +error_setg (errp, +"idreg %s set value (0x%lx) does not match any " +"arch valid enum value!" , name, value); +return ; + } + +/* If the field is RESx or RAZ, it should not be written anything else */ +if (strstr (field->name,"RES0" ) && value !=0 ) { +error_setg (errp,"idreg %s is RES0 field and cannot write %ld" , + name, value); +return ; + }else if (strstr (field->name,"RAZ" ) && value !=0 ) { +error_setg (errp,"idreg %s is RAZ field and cannot write %ld" , + name, value); +return ; + }else if (strstr (field->name,"RES1" ) && value !=1 ) { +error_setg (errp,"idreg %s is RES1 field and cannot write %ld" , + name, value); +return ; + } + +valid: + mask =MAKE_64BIT_MASK (lower, length); + value = value << lower; + old = idregs[index]; + idregs[index] = old & ~mask; + idregs[index] |= value; +trace_set_sysreg_prop (name, old, mask, value, idregs[index]); +} + +static void get_sysreg_prop (Object *obj,Visitor *v, +const char *name,void *opaque, +Error **errp) +{ +ARM64SysRegField *field = (ARM64SysRegField *)opaque; +ARMCPU *cpu =ARM_CPU (obj); +uint64_t *idregs = cpu->isar.idregs; +uint64_t value, mask; +int lower = field->shift; +int length = field->length; +int index = field->index; + + mask =MAKE_64BIT_MASK (lower, length); + value = (idregs[index] & mask) >> lower; +visit_type_uint64 (v, name, &value, errp); +trace_get_sysreg_prop (name, value); +} + +static int +aarch64_add_idreg_properties (Object *obj,ARM64SysReg *reg) +{ +int nb_sysreg_props =0 ; + +for (int i =0 ; i < reg->fields_count; i++) { +ARM64SysRegField *field = ®->fields[i]; +char *prop_name =g_strdup_printf ("SYSREG_%s_%s" , reg->name, + field->name); +object_property_add (obj, prop_name,"uint64" , + get_sysreg_prop, set_sysreg_prop,NULL , field); +g_free (prop_name); + nb_sysreg_props++; + } + +trace_nb_sysreg_props (reg->name, nb_sysreg_props); +return 0 ; +} + +void aarch64_add_idregs_properties (Object *obj) +{ +for (int i =0 ; i <NUM_ID_IDX ; i++) { +ARM64SysReg *reg = &arm64_id_regs[i]; +aarch64_add_idreg_properties (obj, reg); + } +} +#endif +void
aarch64_add_pauth_properties(Object *obj){ ARMCPU *cpu = ARM_CPU(obj);target/arm/cpu64.c +6
-2@@ -865,8 +973,12 @@ static void aarch64_host_initfn(Object *obj)kvm_arm_set_cpu_features_from_host (cpu);aarch64_add_sve_properties (obj); -/* generate SYSREG properties according to writable masks */ -kvm_arm_expose_idreg_properties (cpu, arm64_id_regs); +#ifndef CONFIG_USER_ONLY +/* generate SYSREG properties */ +if (kvm_enabled ()) { +aarch64_add_idregs_properties (obj); + } +#endif #elif defined(CONFIG_HVF )hvf_arm_set_cpu_features_from_host (cpu);target/arm/internals.h +3
-0@@ -1754,6 +1754,9 @@ void aarch64_max_tcg_initfn(Object *obj);void aarch64_add_pauth_properties (Object *obj);void aarch64_add_sve_properties (Object *obj);void aarch64_add_sme_properties (Object *obj); +#ifndef CONFIG_USER_ONLY +void aarch64_add_idregs_properties (Object *obj); +#endif /* Return true if the gdbstub is presenting an AArch64 CPU */ static inline bool arm_gdbstub_is_aarch64 (ARMCPU *cpu)target/arm/kvm.c +0
-151@@ -327,157 +327,6 @@ static int get_host_cpu_idregs(ARMCPU *cpu, int fd, ARMHostCPUFeatures *ahcf)return err; } -static ARM64SysRegField *get_field (int i,ARM64SysReg *reg) -{ -for (int f =0 ; f < reg->fields_count; f++) { -struct ARM64SysRegField *field = ®->fields[f]; -int upper = field->shift + field->length -1 ; - -if (i >= field->shift && i <= upper) { -return field; - } - } -return NULL ; -} - -static void set_sysreg_prop (Object *obj,Visitor *v, -const char *name,void *opaque, -Error **errp) -{ -ARM64SysRegField *field = (ARM64SysRegField *)opaque; -ARMCPU *cpu =ARM_CPU (obj); -uint64_t *idregs = cpu->isar.idregs; -uint64_t old, value, mask; -int lower = field->shift; -int length = field->length; -int index = field->index; - -if (!visit_type_uint64 (v, name, &value, errp)) { -return ; - } - -if (length <64 && value > ((1 << length) -1 )) { -error_setg (errp, -"idreg %s set value (0x%lx) exceeds length of field (%d)!" , - name, value, length); -return ; - } - -if (field->arch_vals) { -/* this field has some enum values */ -for (int i =0 ; i < field->arch_vals_count; i++) { -if (value == field->arch_vals[i].value) { - goto valid; - } - } -error_setg (errp, -"idreg %s set value (0x%lx) does not match any " -"arch valid enum value!" , name, value); -return ; - } - -valid: - - mask =MAKE_64BIT_MASK (lower, length); - value = value << lower; - old = idregs[index]; - idregs[index] = old & ~mask; - idregs[index] |= value; -trace_set_sysreg_prop (name, old, mask, value, idregs[index]); -} - -static void get_sysreg_prop (Object *obj,Visitor *v, -const char *name,void *opaque, -Error **errp) -{ -ARM64SysRegField *field = (ARM64SysRegField *)opaque; -ARMCPU *cpu =ARM_CPU (obj); -uint64_t *idregs = cpu->isar.idregs; -uint64_t value, mask; -int lower = field->shift; -int length = field->length; -int index = field->index; - - mask =MAKE_64BIT_MASK (lower, length); - value = (idregs[index] & mask) >> lower; -visit_type_uint64 (v, name, &value, errp); -trace_get_sysreg_prop (name, value); -} - -/* -* decode_idreg_writemap: Generate props for writable fields -* -* @obj: CPU object -* @reg: description of the sysreg -*/ -static int -decode_idreg_writemap (Object *obj,ARM64SysReg *reg) -{ -uint64_t map = reg->writable_mask; -int i =ctz64 (map); -int nb_sysreg_props =0 ; - -while (map) { -ARM64SysRegField *field =get_field (i, reg); -int lower, upper; -char *prop_name; -uint64_t field_mask; - -if (!field) { -warn_report ("%s bit %d of %s is writable but no named field " -"in target/arm/cpu-idregs.h.inc" , - __func__, i, reg->name); -warn_report ("%s is target/arm/cpu-idregs.h.inc up-to-date?" , __func__); - map = map & ~BIT_ULL (i); - i =ctz64 (map); -continue ; - } - lower = field->shift; - upper = field->shift + field->length -1 ; - -/* Sanity check the field is not a reserved field */ -if (strstr (field->name,"RES0" ) ||strstr (field->name,"RES1" ) || -strstr (field->name,"RAZ" )) { -trace_unexpected_writable_reserved_field (reg->name, field->name, - lower, upper); -continue ; - } - prop_name =g_strdup_printf ("SYSREG_%s_%s" , reg->name, field->name); -trace_decode_idreg_writemap (field->name, lower, upper, prop_name); -object_property_add (obj, prop_name,"uint64" , - get_sysreg_prop, set_sysreg_prop,NULL , field); -g_free (prop_name); - nb_sysreg_props++; - - field_mask =MAKE_64BIT_MASK (lower, field->length); - map = map & ~field_mask; - i =ctz64 (map); - } -trace_nb_sysreg_props (reg->name, nb_sysreg_props); -return 0 ; -} - -/* analyze the writable mask and generate properties for writable fields */ -void kvm_arm_expose_idreg_properties (ARMCPU *cpu,ARM64SysReg *regs) -{ -Object *obj =OBJECT (cpu); - -for (int i =0 ; i <NUM_ID_IDX ; i++) { -ARM64SysReg *sysregdesc = ®s[i]; - -if (sysregdesc->writable_mask) { -/* -* special case REVIDR_EL1 and AIDR_EL1 which are writable but -* do not expose named fields. They will need to be handled -* separately -*/ -if (strcmp (sysregdesc->name,"REVIDR_EL1" ) && -strcmp (sysregdesc->name,"AIDR_EL1" )) { -decode_idreg_writemap (obj, sysregdesc); - } - } - } -}static void
kvm_arm_get_host_cpu_features(ARMCPU *cpu, ARMHostCPUFeatures *ahcf)target/arm/kvm_arm.h +0
-8@@ -143,14 +143,6 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu);void kvm_arm_add_vcpu_properties (ARMCPU *cpu);typedef struct ARM64SysReg ARM64SysReg ; -/** -* kvm_arm_expose_idreg_properties: -* @cpu: The CPU object to generate the properties for -* @reg: registers from the host -* -* analyze the writable mask and generate properties for writable fields -*/ -void kvm_arm_expose_idreg_properties (ARMCPU *cpu,ARM64SysReg *regs);/** * kvm_arm_steal_time_finalize: target/arm/trace-events +0
-0@@ -15,11 +15,11 @@ arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d"
kvm_arm_fixup_msi_route(uint64_t iova, uint64_t gpa)"MSI iova = 0x%"PRIx64" is translated into 0x%"PRIx64get_host_cpu_idregs(const char *name, uint64_t value)"scratch vcpu host value for %s is 0x%"PRIx64kvm_arm_writable_idregs_to_cpreg_list(const char *name, uint64_t previous, uint64_t new)"%s overwrite default 0x%"PRIx64" with 0x%"PRIx64target/arm/trace-events +2
-1-decode_idreg_writemap(const char* name, int lower, int upper, char *prop_name) "%s [%d:%d] is writable (prop %s)" + +# cpu64.c
get_sysreg_prop(const char *name, uint64_t value)"%s 0x%"PRIx64set_sysreg_prop(const char *name, uint64_t old, uint64_t mask, uint64_t field_value, uint64_t new)"%s old reg value=0x%"PRIx64" mask=0x%"PRIx64" new field value=0x%"PRIx64" new reg value=0x%"PRIx64nb_sysreg_props(const char *name, int count)"%s: %d SYSREG properties"
-unexpected_writable_reserved_field(const char*reg_name, const char*field_name, int lower, int upper) "Unexpected writable reserved field: %s.%s [%d,%d], skip it ..."# cpu.c arm_cpu_reset(uint64_t mp_aff) "cpu %" PRIu64
Re: [RFC PATCH v3 04/19] target/arm: expose all ID regs fields as properties
Quoted 77 lines · Khushit Shah
Quoted 72 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 43 lines · Khushit Shah
Quoted 13 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Hi Khushit,
Quoted 3 lines · Khushit Shah
Upcoming named cpu models layer requires exposing all the ID register fields as properties.
Quoted 8 lines
Quoted 3 lines
While doing so also move the code to
cpu64.cto make it accelerator-agnostic, and rename the function toaarch64_add_idregs_properties().Better to split that patch into 2 to ease the review:
1) update the code in kvm to expose all ID regs including those which are not writable and adaptation inset_sysreg_propto handle RAZ, RES0/1, ...
2) Move tocpu64.cThis makes more sense, thanks, will do that in v4.
Quoted 11 lines
To me it is still arguable whether it makes sense to expose settings which cannot be really set. To me It pollutes the qmp introspection output and I don't know whether there is any case history. Why can't we:
- only expose writable id regs as props
- other non writable settings you need to check could be registered in a hash table during named cpu model definition in props.
inarm_apply_model_props()when you enumerate all props you can check if there is an existing prop for this name, in which case you really call
object_property_set_bool(), otherwise, you go through another path, which is not visible by the end user where you check the KVM value matches your "prop" value. No need to pretend this is writable.Please refer to my below text.
Quoted 7 lines
Also I am doubtful about RES/RAZ.
+
MODEL_PROP("SYSREG_CTR_EL0_RES1_31", NUM, 1),does not make sense to me
Why can't you enumate all ID regs and go through those fields and check the KVM value matches. Why would we need to explicitly set a RAS/RES0/1 field. Why can't that be checked transparently.
Quoted 9 lines
Why do we need non-writable field props?:
- Assume some non-writable field mismatches for the model and host, why do we want to stop users from explicitly overriding the model's field value to host value?
- Even with cpu -host, how will upper layer know, if they can migrate between host A and host B? (Without actually doing the migration)
-> Only if all non-writable fields in both host matches
and writable fields in both host are “compatible”.I do agree with you we need to check non writable fields do match. What I am challenging is the fact you want to expose non writable idregs through qemu properties. If it is not writable why would we pretend the end user can change it through the cmd line. You can set the expected field value in the vcpu model description through DEFINEs or whatever method. Then on init, the model will read the host value and fails the init if they don't match. The fact no prop is available for this field would teach the end user the field is not writable.
Quoted 3 lines
The above
MODEL_PROP()could be a wrapper that either sets the actual property if it exists (for a writable field) or just silently populate a table of expected non writable field values that are checked on init, no?Okay, I think here the confusion lies in perspective of writability.
Quoted 7 lines
From my perspective, a field is only host non-writable, i.e. every guest on host should have the same field value.
But this should not restrict model’s field writability. Take the “pauth” example as explained earlier. A field being non-writable does not mean we cannot change model’s value, it only means we cannot change host value, right?
Yes that's what I meant. You need to be able to tell I want this field to be equal to x. If it is not host writable, the model will just read host value and check this latter and x do match, otherwise fail the init. However I advocate for not exposing the field as a true qemu property as it is not host writable.
Eric
Quoted 394 lines
Quoted 8 lines
Quoted 5 lines
Why would we need to explicitly set a RAS/RES0/1 field?
- Here my argument is a little weaker but, what if RES1 field is repurposed in the future? We still want existing models to show 1.AARCHMRS description tells you which fields are RESx. You can read the host value and fails the init in case of mismatch.
I agree, will remove RAS/RES props.
Warm Regards,
KhushitQuoted 381 lines
Thanks
Eric
Quoted 378 lines
RES0 does not need any special handling, only RES1 field needs this special handling.
Does the above arguments make sense?
Warm Regards,
KhushitQuoted 369 lines
Thanks
Eric
Quoted 365 lines
This makes porting this solution to other accelerators easy in future.
Signed-off-by Khushit Shah <[email protected]>---
target/arm/cpu64.c | 116 +++++++++++++++++++++++++++++- target/arm/internals.h | 3 + target/arm/kvm.c | 151 ---------------------------------------- target/arm/kvm_arm.h | 8 --- target/arm/trace-events | 4 +- 5 files changed, 119 insertions(+), 163 deletions(-)target/arm/cpu64.c +1
-0@@ -38,6 +38,7 @@#include "internals.h" #include "cpu-features.h" #include "cpu-idregs.h" +#include "trace.h" /* convert between <register>_IDX and SYS_<register> */ #define DEF (NAME ,OP0 ,OP1 ,CRN ,CRM ,OP2 ) \@@ -644,6 +645,113 @@ static const Property arm_cpu_pauth_qarma3_property =static Property
arm_cpu_pauth_qarma5_property=
DEFINE_PROP_BOOL("pauth-qarma5", ARMCPU, prop_pauth_qarma5, false);target/arm/cpu64.c +107
-0+#ifndef CONFIG_USER_ONLY +static void set_sysreg_prop (Object *obj,Visitor *v, +const char *name,void *opaque, +Error **errp) +{ +ARM64SysRegField *field = (ARM64SysRegField *)opaque; +ARMCPU *cpu =ARM_CPU (obj); +uint64_t *idregs = cpu->isar.idregs; +uint64_t old, value, mask; +int lower = field->shift; +int length = field->length; +int index = field->index; + +if (!visit_type_uint64 (v, name, &value, errp)) { +return ; + } + +if (length <64 && value > ((1ULL << length) -1 )) { +error_setg (errp, +"idreg %s set value (0x%lx) exceeds length of field (%d)!" , + name, value, length); +return ; + } + +if (field->arch_vals) { +/* this field has some enum values */ +for (int i =0 ; i < field->arch_vals_count; i++) { +if (value == field->arch_vals[i].value) { + goto valid; + } + } +error_setg (errp, +"idreg %s set value (0x%lx) does not match any " +"arch valid enum value!" , name, value); +return ; + } + +/* If the field is RESx or RAZ, it should not be written anything else */ +if (strstr (field->name,"RES0" ) && value !=0 ) { +error_setg (errp,"idreg %s is RES0 field and cannot write %ld" , + name, value); +return ; + }else if (strstr (field->name,"RAZ" ) && value !=0 ) { +error_setg (errp,"idreg %s is RAZ field and cannot write %ld" , + name, value); +return ; + }else if (strstr (field->name,"RES1" ) && value !=1 ) { +error_setg (errp,"idreg %s is RES1 field and cannot write %ld" , + name, value); +return ; + } + +valid: + mask =MAKE_64BIT_MASK (lower, length); + value = value << lower; + old = idregs[index]; + idregs[index] = old & ~mask; + idregs[index] |= value; +trace_set_sysreg_prop (name, old, mask, value, idregs[index]); +} + +static void get_sysreg_prop (Object *obj,Visitor *v, +const char *name,void *opaque, +Error **errp) +{ +ARM64SysRegField *field = (ARM64SysRegField *)opaque; +ARMCPU *cpu =ARM_CPU (obj); +uint64_t *idregs = cpu->isar.idregs; +uint64_t value, mask; +int lower = field->shift; +int length = field->length; +int index = field->index; + + mask =MAKE_64BIT_MASK (lower, length); + value = (idregs[index] & mask) >> lower; +visit_type_uint64 (v, name, &value, errp); +trace_get_sysreg_prop (name, value); +} + +static int +aarch64_add_idreg_properties (Object *obj,ARM64SysReg *reg) +{ +int nb_sysreg_props =0 ; + +for (int i =0 ; i < reg->fields_count; i++) { +ARM64SysRegField *field = ®->fields[i]; +char *prop_name =g_strdup_printf ("SYSREG_%s_%s" , reg->name, + field->name); +object_property_add (obj, prop_name,"uint64" , + get_sysreg_prop, set_sysreg_prop,NULL , field); +g_free (prop_name); + nb_sysreg_props++; + } + +trace_nb_sysreg_props (reg->name, nb_sysreg_props); +return 0 ; +} + +void aarch64_add_idregs_properties (Object *obj) +{ +for (int i =0 ; i <NUM_ID_IDX ; i++) { +ARM64SysReg *reg = &arm64_id_regs[i]; +aarch64_add_idreg_properties (obj, reg); + } +} +#endif +void
aarch64_add_pauth_properties(Object *obj){ ARMCPU *cpu = ARM_CPU(obj);target/arm/cpu64.c +6
-2@@ -865,8 +973,12 @@ static void aarch64_host_initfn(Object *obj)kvm_arm_set_cpu_features_from_host (cpu);aarch64_add_sve_properties (obj); -/* generate SYSREG properties according to writable masks */ -kvm_arm_expose_idreg_properties (cpu, arm64_id_regs); +#ifndef CONFIG_USER_ONLY +/* generate SYSREG properties */ +if (kvm_enabled ()) { +aarch64_add_idregs_properties (obj); + } +#endif #elif defined(CONFIG_HVF )hvf_arm_set_cpu_features_from_host (cpu);target/arm/internals.h +3
-0@@ -1754,6 +1754,9 @@ void aarch64_max_tcg_initfn(Object *obj);void aarch64_add_pauth_properties (Object *obj);void aarch64_add_sve_properties (Object *obj);void aarch64_add_sme_properties (Object *obj); +#ifndef CONFIG_USER_ONLY +void aarch64_add_idregs_properties (Object *obj); +#endif /* Return true if the gdbstub is presenting an AArch64 CPU */ static inline bool arm_gdbstub_is_aarch64 (ARMCPU *cpu)target/arm/kvm.c +0
-151@@ -327,157 +327,6 @@ static int get_host_cpu_idregs(ARMCPU *cpu, int fd, ARMHostCPUFeatures *ahcf)return err; } -static ARM64SysRegField *get_field (int i,ARM64SysReg *reg) -{ -for (int f =0 ; f < reg->fields_count; f++) { -struct ARM64SysRegField *field = ®->fields[f]; -int upper = field->shift + field->length -1 ; - -if (i >= field->shift && i <= upper) { -return field; - } - } -return NULL ; -} - -static void set_sysreg_prop (Object *obj,Visitor *v, -const char *name,void *opaque, -Error **errp) -{ -ARM64SysRegField *field = (ARM64SysRegField *)opaque; -ARMCPU *cpu =ARM_CPU (obj); -uint64_t *idregs = cpu->isar.idregs; -uint64_t old, value, mask; -int lower = field->shift; -int length = field->length; -int index = field->index; - -if (!visit_type_uint64 (v, name, &value, errp)) { -return ; - } - -if (length <64 && value > ((1 << length) -1 )) { -error_setg (errp, -"idreg %s set value (0x%lx) exceeds length of field (%d)!" , - name, value, length); -return ; - } - -if (field->arch_vals) { -/* this field has some enum values */ -for (int i =0 ; i < field->arch_vals_count; i++) { -if (value == field->arch_vals[i].value) { - goto valid; - } - } -error_setg (errp, -"idreg %s set value (0x%lx) does not match any " -"arch valid enum value!" , name, value); -return ; - } - -valid: - - mask =MAKE_64BIT_MASK (lower, length); - value = value << lower; - old = idregs[index]; - idregs[index] = old & ~mask; - idregs[index] |= value; -trace_set_sysreg_prop (name, old, mask, value, idregs[index]); -} - -static void get_sysreg_prop (Object *obj,Visitor *v, -const char *name,void *opaque, -Error **errp) -{ -ARM64SysRegField *field = (ARM64SysRegField *)opaque; -ARMCPU *cpu =ARM_CPU (obj); -uint64_t *idregs = cpu->isar.idregs; -uint64_t value, mask; -int lower = field->shift; -int length = field->length; -int index = field->index; - - mask =MAKE_64BIT_MASK (lower, length); - value = (idregs[index] & mask) >> lower; -visit_type_uint64 (v, name, &value, errp); -trace_get_sysreg_prop (name, value); -} - -/* -* decode_idreg_writemap: Generate props for writable fields -* -* @obj: CPU object -* @reg: description of the sysreg -*/ -static int -decode_idreg_writemap (Object *obj,ARM64SysReg *reg) -{ -uint64_t map = reg->writable_mask; -int i =ctz64 (map); -int nb_sysreg_props =0 ; - -while (map) { -ARM64SysRegField *field =get_field (i, reg); -int lower, upper; -char *prop_name; -uint64_t field_mask; - -if (!field) { -warn_report ("%s bit %d of %s is writable but no named field " -"in target/arm/cpu-idregs.h.inc" , - __func__, i, reg->name); -warn_report ("%s is target/arm/cpu-idregs.h.inc up-to-date?" , __func__); - map = map & ~BIT_ULL (i); - i =ctz64 (map); -continue ; - } - lower = field->shift; - upper = field->shift + field->length -1 ; - -/* Sanity check the field is not a reserved field */ -if (strstr (field->name,"RES0" ) ||strstr (field->name,"RES1" ) || -strstr (field->name,"RAZ" )) { -trace_unexpected_writable_reserved_field (reg->name, field->name, - lower, upper); -continue ; - } - prop_name =g_strdup_printf ("SYSREG_%s_%s" , reg->name, field->name); -trace_decode_idreg_writemap (field->name, lower, upper, prop_name); -object_property_add (obj, prop_name,"uint64" , - get_sysreg_prop, set_sysreg_prop,NULL , field); -g_free (prop_name); - nb_sysreg_props++; - - field_mask =MAKE_64BIT_MASK (lower, field->length); - map = map & ~field_mask; - i =ctz64 (map); - } -trace_nb_sysreg_props (reg->name, nb_sysreg_props); -return 0 ; -} - -/* analyze the writable mask and generate properties for writable fields */ -void kvm_arm_expose_idreg_properties (ARMCPU *cpu,ARM64SysReg *regs) -{ -Object *obj =OBJECT (cpu); - -for (int i =0 ; i <NUM_ID_IDX ; i++) { -ARM64SysReg *sysregdesc = ®s[i]; - -if (sysregdesc->writable_mask) { -/* -* special case REVIDR_EL1 and AIDR_EL1 which are writable but -* do not expose named fields. They will need to be handled -* separately -*/ -if (strcmp (sysregdesc->name,"REVIDR_EL1" ) && -strcmp (sysregdesc->name,"AIDR_EL1" )) { -decode_idreg_writemap (obj, sysregdesc); - } - } - } -}static void
kvm_arm_get_host_cpu_features(ARMCPU *cpu, ARMHostCPUFeatures *ahcf)target/arm/kvm_arm.h +0
-8@@ -143,14 +143,6 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu);void kvm_arm_add_vcpu_properties (ARMCPU *cpu);typedef struct ARM64SysReg ARM64SysReg ; -/** -* kvm_arm_expose_idreg_properties: -* @cpu: The CPU object to generate the properties for -* @reg: registers from the host -* -* analyze the writable mask and generate properties for writable fields -*/ -void kvm_arm_expose_idreg_properties (ARMCPU *cpu,ARM64SysReg *regs);/** * kvm_arm_steal_time_finalize: target/arm/trace-events +0
-0@@ -15,11 +15,11 @@ arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d"
kvm_arm_fixup_msi_route(uint64_t iova, uint64_t gpa)"MSI iova = 0x%"PRIx64" is translated into 0x%"PRIx64get_host_cpu_idregs(const char *name, uint64_t value)"scratch vcpu host value for %s is 0x%"PRIx64kvm_arm_writable_idregs_to_cpreg_list(const char *name, uint64_t previous, uint64_t new)"%s overwrite default 0x%"PRIx64" with 0x%"PRIx64target/arm/trace-events +2
-1-decode_idreg_writemap(const char* name, int lower, int upper, char *prop_name) "%s [%d:%d] is writable (prop %s)" + +# cpu64.c
get_sysreg_prop(const char *name, uint64_t value)"%s 0x%"PRIx64set_sysreg_prop(const char *name, uint64_t old, uint64_t mask, uint64_t field_value, uint64_t new)"%s old reg value=0x%"PRIx64" mask=0x%"PRIx64" new field value=0x%"PRIx64" new reg value=0x%"PRIx64nb_sysreg_props(const char *name, int count)"%s: %d SYSREG properties"
-unexpected_writable_reserved_field(const char*reg_name, const char*field_name, int lower, int upper) "Unexpected writable reserved field: %s.%s [%d,%d], skip it ..."# cpu.c arm_cpu_reset(uint64_t mp_aff) "cpu %" PRIu64
RFC PATCH v3 5/19 target/arm/kvm: enable writable implementation ID registers
In reply to Khushit ShahEnable KVM_CAP_ARM_WRITABLE_IMP_ID_REGS if the host kernel supports it. This allows QEMU to write implementation-defined ID registers (MIDR, REVIDR) so that named CPU models can present the correct values to the guest instead of inheriting the host's identity.
--- target/arm/kvm.c | 7 +++++++ 1 file changed, 7 insertions(+)
target/arm/kvm.c +7 -0
@@ -741,6 +741,13 @@ int kvm_arch_init(MachineState *ms, KVMState *s) } } +if (kvm_check_extension (s,KVM_CAP_ARM_WRITABLE_IMP_ID_REGS )) { +if (kvm_vm_enable_cap (s,KVM_CAP_ARM_WRITABLE_IMP_ID_REGS ,0 )) { +error_report ("Failed to enable " +"KVM_CAP_ARM_WRITABLE_IMP_ID_REGS cap" ); + } + } +if (s->kvm_eager_split_size) {uint32_t sizes;
Signature · 1 line
2.52.0
Re: [RFC PATCH v3 05/19] target/arm/kvm: enable writable implementation ID registers
Hi Khushit,
Quoted 4 lines · Khushit Shah
Enable
KVM_CAP_ARM_WRITABLE_IMP_ID_REGSif the host kernel supports it. This allows QEMU to write implementation-defined ID registers (MIDR, REVIDR) so that named CPU models can present the correct values to the guest instead of inheriting the host's identity.
This is a subset of
[RFC PATCH RESEND 0/4] hw/arm/virt: Add support for Target Implementation CPUs
https://lore.kernel.org/all/[email protected]/
and especially 1/4
Thanks
Eric
Quoted 24 lines
Signed-off-by Khushit Shah <[email protected]>--- target/arm/kvm.c | 7 +++++++ 1 file changed, 7 insertions(+)target/arm/kvm.c +7
-0@@ -741,6 +741,13 @@ int kvm_arch_init(MachineState *ms, KVMState *s) } } +if (kvm_check_extension (s,KVM_CAP_ARM_WRITABLE_IMP_ID_REGS )) { +if (kvm_vm_enable_cap (s,KVM_CAP_ARM_WRITABLE_IMP_ID_REGS ,0 )) { +error_report ("Failed to enable " +"KVM_CAP_ARM_WRITABLE_IMP_ID_REGS cap" ); + } + } +if (s->kvm_eager_split_size) {uint32_t sizes;
Re: [RFC PATCH v3 05/19] target/arm/kvm: enable writable implementation ID registers
Quoted 16 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Hi Khushit,
Quoted 4 lines · Khushit Shah
Enable
KVM_CAP_ARM_WRITABLE_IMP_ID_REGSif the host kernel supports it. This allows QEMU to write implementation-defined ID registers (MIDR, REVIDR) so that named CPU models can present the correct values to the guest instead of inheriting the host's identity.
Quoted 6 lines
This is a subset of
[RFC PATCH RESEND 0/4] hw/arm/virt: Add support for Target Implementation CPUs
https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_all_20250801074730.28329-2D1-2Dshameerkolothum-40gmail.com_&d=DwIDaQ&c=s883GpUCOChKOHiocYtGcg&r=PGWMyignA0NiDmTlyP7vOTHozBws_VN86yrVmSMkBp0&m=pBBhKggpCKeDS4Sd7cXd8E5Cqhh-WjEbkh5Q-cSe_INp0NjOj69sFVBbwOAg7Pp1&s=Q-vKi5MLWdCzdKdXMUZ3wONnjAI6zV0Riawwl4UuVyo&e=and especially 1/4
Okay, interesting! I will look into the series.
Warm Regards,
Khushit.
Quoted 30 lines
Thanks
Eric
Quoted 24 lines
Signed-off-by Khushit Shah <[email protected]>---
target/arm/kvm.c| 7 +++++++1 file changed, 7 insertions(+)target/arm/kvm.c +7
-0@@ -741,6 +741,13 @@ int kvm_arch_init(MachineState *ms, KVMState *s) } } +if (kvm_check_extension (s,KVM_CAP_ARM_WRITABLE_IMP_ID_REGS )) { +if (kvm_vm_enable_cap (s,KVM_CAP_ARM_WRITABLE_IMP_ID_REGS ,0 )) { +error_report ("Failed to enable " +"KVM_CAP_ARM_WRITABLE_IMP_ID_REGS cap" ); + } + } +if (s->kvm_eager_split_size) {uint32_t sizes;
RFC PATCH v3 6/19 target/arm/kvm: Read all ID registers from KVM
In reply to Khushit ShahTry to read all the ID registers from KVM. KVM may return ENOENT, for ID registers it does not support reading from userspace. Ignore those registers. As this list is small, in future we may anyway want to handle those register specially.
We want to do this so that we can expose more or less complete host feature view to management stack, as for migration, we want both writable and non-writable ID registers to match.
Also remove the unused 'cpu' args throughout the call-chain.
--- target/arm/kvm.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-)
target/arm/kvm.c +19 -19
@@ -292,14 +292,14 @@ static int kvm_feature_idx_to_idregs_idx(int kidx) }/* -* get_host_cpu_idregs: Read all the writable ID reg host values +* get_host_cpu_idregs: Read all the ID reg host values * -* Need to be called once the writable mask has been populated -* Note we may want to read all the known id regs but some of them are not -* writable and return an error, hence the choice of reading only those which -* are writable. Those are also readable! +* We currently try to read all the registers. If the read fails with +* ENOENT (KVM does not identify the ID register) ignore it. +* Some of the registers that errored with ENOENT will anyway need special +* handling. */ -static int get_host_cpu_idregs (ARMCPU *cpu,int fd,ARMHostCPUFeatures *ahcf) +static int get_host_cpu_idregs (int fd,ARMHostCPUFeatures *ahcf) {int err =0 ;int i;
@@ -310,26 +310,26 @@ static int get_host_cpu_idregs(ARMCPU *cpu, int fd, ARMHostCPUFeatures *ahcf)uint64_t *reg;int ret; -if (!sysregdesc->writable_mask) { -continue ; - } - reg = &ahcf->isar.idregs[i]; ret =read_sys_reg64 (fd, reg,idregs_sysreg_to_kvm_reg (sysreg)); -trace_get_host_cpu_idregs (sysregdesc->name, *reg);if (ret) { -error_report ("%s error reading value of host %s register (%m)" , - __func__, sysregdesc->name); - - err = ret; +if (errno ==ENOENT ) { +warn_report ("%s error reading value of host %s register " +"(ENOENT)" , __func__, sysregdesc->name); + }else { +error_report ("%s error reading value of host %s register" +" (%m)" , __func__, sysregdesc->name); + err = ret; + } } +trace_get_host_cpu_idregs (sysregdesc->name, *reg); }return err; }static void -kvm_arm_get_host_cpu_features (ARMCPU *cpu,ARMHostCPUFeatures *ahcf) +kvm_arm_get_host_cpu_features (ARMHostCPUFeatures *ahcf) {/* Identify the feature bits corresponding to the host CPU, and * fill out the ARMHostCPUClass fields accordingly. To do this
@@ -415,8 +415,8 @@ kvm_arm_get_host_cpu_features(ARMCPU *cpu, ARMHostCPUFeatures *ahcf)SET_IDREG (&ahcf->isar,ID_AA64PFR0 ,0x00000011 );/* EL1&0, AArch64 only */ err =0 ; }else { -/* Make sure all writable ID reg values are initialized */ - err |=get_host_cpu_idregs (cpu, fd, ahcf); +/* Try to read all the ID registers */ + err |=get_host_cpu_idregs (fd, ahcf);/* * temporarily override the CLIDR_EL1 value since some host values
@@ -595,7 +595,7 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu)g_free (writable_map);if (!arm_host_cpu_features.dtb_compatible) { -kvm_arm_get_host_cpu_features (cpu, &arm_host_cpu_features); +kvm_arm_get_host_cpu_features (&arm_host_cpu_features); } cpu->kvm_target = arm_host_cpu_features.target;
Signature · 1 line
2.52.0
Re: [RFC PATCH v3 06/19] target/arm/kvm: Read all ID registers from KVM
Quoted 10 lines · Khushit Shah
Try to read all the ID registers from KVM. KVM may return ENOENT, for ID registers it does not support reading from userspace. Ignore those registers. As this list is small, in future we may anyway want to handle those register specially.
We want to do this so that we can expose more or less complete host feature view to management stack, as for migration, we want both writable and non-writable ID registers to match.
Also remove the unused 'cpu' args throughout the call-chain.
I will integrate this fix in the parent series
Quoted 40 lines
Signed-off-by Khushit Shah <[email protected]>--- target/arm/kvm.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-)target/arm/kvm.c +6
-10@@ -292,14 +292,14 @@ static int kvm_feature_idx_to_idregs_idx(int kidx) }/* -* get_host_cpu_idregs: Read all the writable ID reg host values +* get_host_cpu_idregs: Read all the ID reg host values * -* Need to be called once the writable mask has been populated -* Note we may want to read all the known id regs but some of them are not -* writable and return an error, hence the choice of reading only those which -* are writable. Those are also readable! +* We currently try to read all the registers. If the read fails with +* ENOENT (KVM does not identify the ID register) ignore it. +* Some of the registers that errored with ENOENT will anyway need special +* handling. */ -static int get_host_cpu_idregs (ARMCPU *cpu,int fd,ARMHostCPUFeatures *ahcf) +static int get_host_cpu_idregs (int fd,ARMHostCPUFeatures *ahcf) {int err =0 ;int i;@@ -310,26 +310,26 @@ static int get_host_cpu_idregs(ARMCPU *cpu, int fd, ARMHostCPUFeatures *ahcf)uint64_t *reg;int ret; -if (!sysregdesc->writable_mask) { -continue ; - } - reg = &ahcf->isar.idregs[i];
target/arm/kvm.c static int get_host_cpu_idregs(ARMCPU *cpu, int fd, ARMHostCPUFeatures *ahcf) · line 318
Quoted 10 lines
target/arm/kvm.c +3
-5ret =read_sys_reg64 (fd, reg,idregs_sysreg_to_kvm_reg (sysreg)); -trace_get_host_cpu_idregs (sysregdesc->name, *reg);if (ret) { -error_report ("%s error reading value of host %s register (%m)" , - __func__, sysregdesc->name); - - err = ret; +if (errno ==ENOENT ) { +warn_report ("%s error reading value of host %s register " +"(ENOENT)" , __func__, sysregdesc->name);
if there are expected cases where the read is failing I don't think we want to warn. Add a trace point instead.
Quoted 30 lines
target/arm/kvm.c +9
-3+ }else { +error_report ("%s error reading value of host %s register" +" (%m)" , __func__, sysregdesc->name); + err = ret; + } } +trace_get_host_cpu_idregs (sysregdesc->name, *reg); }return err; }static void -kvm_arm_get_host_cpu_features (ARMCPU *cpu,ARMHostCPUFeatures *ahcf) +kvm_arm_get_host_cpu_features (ARMHostCPUFeatures *ahcf) {/* Identify the feature bits corresponding to the host CPU, and * fill out the ARMHostCPUClass fields accordingly. To do this @@ -415,8 +415,8 @@ kvm_arm_get_host_cpu_features(ARMCPU *cpu, ARMHostCPUFeatures *ahcf)SET_IDREG (&ahcf->isar,ID_AA64PFR0 ,0x00000011 );/* EL1&0, AArch64 only */ err =0 ; }else { -/* Make sure all writable ID reg values are initialized */ - err |=get_host_cpu_idregs (cpu, fd, ahcf); +/* Try to read all the ID registers */ + err |=get_host_cpu_idregs (fd, ahcf);/* * temporarily override the CLIDR_EL1 value since some host values
target/arm/kvm.c void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) · line 601
Quoted 8 lines
target/arm/kvm.c +1
-1@@ -595,7 +595,7 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu)g_free (writable_map);if (!arm_host_cpu_features.dtb_compatible) { -kvm_arm_get_host_cpu_features (cpu, &arm_host_cpu_features); +kvm_arm_get_host_cpu_features (&arm_host_cpu_features); } cpu->kvm_target = arm_host_cpu_features.target;
Thanks
Eric
Re: [RFC PATCH v3 06/19] target/arm/kvm: Read all ID registers from KVM
Quoted 17 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 5 lines · Khushit Shah
Try to read all the ID registers from KVM. KVM may return ENOENT, for ID registers it does not support reading from userspace. Ignore those registers. As this list is small, in future we may anyway want to handle those register specially.
Quoted 6 lines
Quoted 5 lines
We want to do this so that we can expose more or less complete host feature view to management stack, as for migration, we want both writable and non-writable ID registers to match.
Also remove the unused 'cpu' args throughout the call-chain.
I will integrate this fix in the parent series
Acked.
Quoted 44 lines
Quoted 44 lines
Signed-off-by Khushit Shah <[email protected]>---
target/arm/kvm.c| 38 +++++++++++++++++++-------------------1 file changed, 19 insertions(+), 19 deletions(-)target/arm/kvm.c +6
-12@@ -292,14 +292,14 @@ static int kvm_feature_idx_to_idregs_idx(int kidx) }/* -* get_host_cpu_idregs: Read all the writable ID reg host values +* get_host_cpu_idregs: Read all the ID reg host values * -* Need to be called once the writable mask has been populated -* Note we may want to read all the known id regs but some of them are not -* writable and return an error, hence the choice of reading only those which -* are writable. Those are also readable! +* We currently try to read all the registers. If the read fails with +* ENOENT (KVM does not identify the ID register) ignore it. +* Some of the registers that errored with ENOENT will anyway need special +* handling. */ -static int get_host_cpu_idregs (ARMCPU *cpu,int fd,ARMHostCPUFeatures *ahcf) +static int get_host_cpu_idregs (int fd,ARMHostCPUFeatures *ahcf) {int err =0 ;int i;@@ -310,26 +310,26 @@ static int get_host_cpu_idregs(ARMCPU *cpu, int fd, ARMHostCPUFeatures *ahcf)uint64_t *reg;int ret; -if (!sysregdesc->writable_mask) { -continue ; - } - reg = &ahcf->isar.idregs[i]; ret =read_sys_reg64 (fd, reg,idregs_sysreg_to_kvm_reg (sysreg)); -trace_get_host_cpu_idregs (sysregdesc->name, *reg);if (ret) { - error_report("%s error reading value of host %s register (%m)",
Quoted 8 lines
target/arm/kvm.c static int get_host_cpu_idregs(ARMCPU *cpu, int fd, ARMHostCPUFeatures *ahcf) · line 318
Quoted 6 lines
target/arm/kvm.c +3
-3- __func__, sysregdesc->name); - - err = ret; +if (errno ==ENOENT ) { +warn_report ("%s error reading value of host %s register " +"(ENOENT)" , __func__, sysregdesc->name);if there are expected cases where the read is failing I don't think we want to warn. Add a trace point instead.
Acked, will change to tracepoint in v4.
Quoted 41 lines
Quoted 30 lines
target/arm/kvm.c +6
-0+ }else { +error_report ("%s error reading value of host %s register" +" (%m)" , __func__, sysregdesc->name); + err = ret; + } } +trace_get_host_cpu_idregs (sysregdesc->name, *reg); }return err; }static void
target/arm/kvm.c +1
-1-kvm_arm_get_host_cpu_features (ARMCPU *cpu, ARMHostCPUFeatures *ahcf) +kvm_arm_get_host_cpu_features (ARMHostCPUFeatures *ahcf){
/* Identify the feature bits corresponding to the host CPU, and
* fill out the ARMHostCPUClass fields accordingly. To do thistarget/arm/kvm.c +2
-2@@ -415,8 +415,8 @@ kvm_arm_get_host_cpu_features(ARMCPU *cpu, ARMHostCPUFeatures *ahcf)SET_IDREG (&ahcf->isar,ID_AA64PFR0 ,0x00000011 );/* EL1&0, AArch64 only */ err =0 ; }else { -/* Make sure all writable ID reg values are initialized */ - err |=get_host_cpu_idregs (cpu, fd, ahcf); +/* Try to read all the ID registers */ + err |=get_host_cpu_idregs (fd, ahcf);/* * temporarily override the CLIDR_EL1 value since some host values target/arm/kvm.c void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) · line 601
Quoted 8 lines
target/arm/kvm.c +1
-1@@ -595,7 +595,7 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu)g_free (writable_map);if (!arm_host_cpu_features.dtb_compatible) { -kvm_arm_get_host_cpu_features (cpu, &arm_host_cpu_features); +kvm_arm_get_host_cpu_features (&arm_host_cpu_features); } cpu->kvm_target = arm_host_cpu_features.target;Thanks
Eric
RFC PATCH v3 7/19 target/arm/kvm: handle special ID registers cases when reading from KVM
In reply to Khushit ShahThe generic KVM_GET_ONE_REG loop cannot correctly read a handful of ID registers, so specially handle those:
- DCZID_EL0: No fine grain trap exists, hence not tracked by KVM. It is EL0-readable and untrapped, so read it directly with MRS.
- CCSIDR_EL1/CCSIDR2_EL1: not plain ID registers, their value is selected by CSSELR_EL1. KVM only exposes them via the DEMUX API (KVM_REG_ARM_DEMUX_ID_CCSIDR), so there is no single value to read here. Skip them.
- SMIDR_EL1: KVM does not support SME, so there is no meaningful host value. Skip it.
- GMID_EL1: not in KVM's sys_reg_descs[] and, being an EL1 register, cannot be read from userspace via MRS either. The guest reads the raw host value; this is a genuine miss when MTE is enabled.
--- target/arm/kvm.c | 53 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 9 deletions(-)
target/arm/kvm.c +44 -9
@@ -311,15 +311,50 @@ static int get_host_cpu_idregs(int fd, ARMHostCPUFeatures *ahcf)int ret; reg = &ahcf->isar.idregs[i]; - ret =read_sys_reg64 (fd, reg,idregs_sysreg_to_kvm_reg (sysreg)); -if (ret) { -if (errno ==ENOENT ) { -warn_report ("%s error reading value of host %s register " -"(ENOENT)" , __func__, sysregdesc->name); - }else { -error_report ("%s error reading value of host %s register" -" (%m)" , __func__, sysregdesc->name); - err = ret; +switch (i) { +case DCZID_EL0_IDX : +/* +* DCZID_EL0 is not in KVM's sys_reg_descs[], so +* KVM_GET_ONE_REG will fail. Read it directly from +* hardware since KVM doesn't trap guest reads of it. +*/ + asmvolatile ("mrs %0, DCZID_EL0" :"=r" (*reg)); +break ; +case CCSIDR_EL1_IDX : +case CCSIDR2_EL1_IDX : +/* +* CCSIDR_EL1 is not a plain ID register: the value it +* returns is selected by CSSELR_EL1, so there is no single +* value to capture here. It is exposed to userspace only via +* the DEMUX API (KVM_REG_ARM_DEMUX_ID_CCSIDR), indexed by +* CSSELR. Skip reading it here as there is no meaningful host +* value to read. +*/ +break ; +case SMIDR_EL1_IDX : +/* +* As SME is not yet supported by KVM, ignore reading SMIDR_EL1 +*/ +break ; +case GMID_EL1_IDX : +/* +* GMID_EL1 is not in KVM's sys_reg_descs[] and guest reads +* the raw host value. But as it is an EL1 register, we cannot +* read it directly. This is a genuine miss when MTE is +* enabled for the guest. +*/ +break ; +default : + ret =read_sys_reg64 (fd, reg,idregs_sysreg_to_kvm_reg (sysreg)); +if (ret) { +if (errno ==ENOENT ) { +warn_report ("%s error reading value of host %s register " +"(ENOENT)" , __func__, sysregdesc->name); + }else { +error_report ("%s error reading value of host %s register" +" (%m)" , __func__, sysregdesc->name); + err = ret; + } } }trace_get_host_cpu_idregs (sysregdesc->name, *reg);
Signature · 1 line
2.52.0
Re: [RFC PATCH v3 07/19] target/arm/kvm: handle special ID registers cases when reading from KVM
Hi Khushit,
Quoted 49 lines · Khushit Shah
The generic
KVM_GET_ONE_REGloop cannot correctly read a handful of ID registers, so specially handle those:-
DCZID_EL0: No fine grain trap exists, hence not tracked by KVM. It is EL0-readable and untrapped, so read it directly with MRS.- CCSIDR_EL1/CCSIDR2_EL1: not plain ID registers, their value is selected by
CSSELR_EL1. KVM only exposes them via the DEMUX API (KVM_REG_ARM_DEMUX_ID_CCSIDR), so there is no single value to read here. Skip them.-
SMIDR_EL1: KVM does not support SME, so there is no meaningful host value. Skip it.-
GMID_EL1: not in KVM's sys_reg_descs[] and, being an EL1 register, cannot be read from userspace via MRS either. The guest reads the raw host value; this is a genuine miss when MTE is enabled.Signed-off-by Khushit Shah <[email protected]>--- target/arm/kvm.c | 53 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 9 deletions(-)target/arm/kvm.c +9
-9@@ -311,15 +311,50 @@ static int get_host_cpu_idregs(int fd, ARMHostCPUFeatures *ahcf)int ret; reg = &ahcf->isar.idregs[i]; - ret =read_sys_reg64 (fd, reg,idregs_sysreg_to_kvm_reg (sysreg)); -if (ret) { -if (errno ==ENOENT ) { -warn_report ("%s error reading value of host %s register " -"(ENOENT)" , __func__, sysregdesc->name); - }else { -error_report ("%s error reading value of host %s register" -" (%m)" , __func__, sysregdesc->name); - err = ret; +switch (i) { +case DCZID_EL0_IDX : +/* +* DCZID_EL0 is not in KVM's sys_reg_descs[], so +* KVM_GET_ONE_REG will fail. Read it directly from +* hardware since KVM doesn't trap guest reads of it. +*/ + asmvolatile ("mrs %0, DCZID_EL0" :"=r" (*reg)); +break ;
target/arm/kvm.c static int get_host_cpu_idregs(int fd, ARMHostCPUFeatures *ahcf) · line 332
Quoted 10 lines
target/arm/kvm.c +10
-0+case CCSIDR_EL1_IDX : +case CCSIDR2_EL1_IDX : +/* +* CCSIDR_EL1 is not a plain ID register: the value it +* returns is selected by CSSELR_EL1, so there is no single +* value to capture here. It is exposed to userspace only via +* the DEMUX API (KVM_REG_ARM_DEMUX_ID_CCSIDR), indexed by +* CSSELR. Skip reading it here as there is no meaningful host +* value to read. +*/
I think you should rely on prerequisite
[PATCH v4 3/3] arm/kvm: get demuxed ID registers from kvm
Quoted 10 lines
target/arm/kvm.c +10
-0+break ; +case SMIDR_EL1_IDX : +/* +* As SME is not yet supported by KVM, ignore reading SMIDR_EL1 +*/ +break ; +case GMID_EL1_IDX : +/* +* GMID_EL1 is not in KVM's sys_reg_descs[] and guest reads +* the raw host value. But as it is an EL1 register, we cannot
target/arm/kvm.c static int get_host_cpu_idregs(int fd, ARMHostCPUFeatures *ahcf) · line 352
Quoted 10 lines
target/arm/kvm.c +10
-0+* read it directly. This is a genuine miss when MTE is +* enabled for the guest. +*/ +break ; +default : + ret =read_sys_reg64 (fd, reg,idregs_sysreg_to_kvm_reg (sysreg)); +if (ret) { +if (errno ==ENOENT ) { +warn_report ("%s error reading value of host %s register " +"(ENOENT)" , __func__, sysregdesc->name);
trace point
target/arm/kvm.c static int get_host_cpu_idregs(int fd, ARMHostCPUFeatures *ahcf) · line 360
Quoted 8 lines
target/arm/kvm.c +5
-0+ }else { +error_report ("%s error reading value of host %s register" +" (%m)" , __func__, sysregdesc->name); + err = ret; + } } }trace_get_host_cpu_idregs (sysregdesc->name, *reg);
Thanks
Eric
Re: [RFC PATCH v3 07/19] target/arm/kvm: handle special ID registers cases when reading from KVM
Quoted 65 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Hi Khushit,
Quoted 53 lines · Khushit Shah
The generic
KVM_GET_ONE_REGloop cannot correctly read a handful of ID registers, so specially handle those:-
DCZID_EL0: No fine grain trap exists, hence not tracked by KVM. It is EL0-readable and untrapped, so read it directly with MRS.- CCSIDR_EL1/CCSIDR2_EL1: not plain ID registers, their value is selected by
CSSELR_EL1. KVM only exposes them via the DEMUX API (KVM_REG_ARM_DEMUX_ID_CCSIDR), so there is no single value to read here. Skip them.-
SMIDR_EL1: KVM does not support SME, so there is no meaningful host value. Skip it.-
GMID_EL1: not in KVM's sys_reg_descs[] and, being an EL1 register, cannot be read from userspace via MRS either. The guest reads the raw host value; this is a genuine miss when MTE is enabled.Signed-off-by Khushit Shah <[email protected]>---
target/arm/kvm.c| 53 ++++++++++++++++++++++++++++++++++++++++--------1 file changed, 44 insertions(+), 9 deletions(-)target/arm/kvm.c +13
-9@@ -311,15 +311,50 @@ static int get_host_cpu_idregs(int fd, ARMHostCPUFeatures *ahcf)int ret; reg = &ahcf->isar.idregs[i]; - ret =read_sys_reg64 (fd, reg,idregs_sysreg_to_kvm_reg (sysreg)); -if (ret) { -if (errno ==ENOENT ) { -warn_report ("%s error reading value of host %s register " -"(ENOENT)" , __func__, sysregdesc->name); - }else { -error_report ("%s error reading value of host %s register" -" (%m)" , __func__, sysregdesc->name); - err = ret; +switch (i) { +case DCZID_EL0_IDX : +/* +* DCZID_EL0 is not in KVM's sys_reg_descs[], so +* KVM_GET_ONE_REG will fail. Read it directly from +* hardware since KVM doesn't trap guest reads of it. +*/ + asmvolatile ("mrs %0, DCZID_EL0" :"=r" (*reg)); +break ; +case CCSIDR_EL1_IDX : +case CCSIDR2_EL1_IDX : +/* +* CCSIDR_EL1 is not a plain ID register: the value it
Quoted 8 lines
target/arm/kvm.c static int get_host_cpu_idregs(int fd, ARMHostCPUFeatures *ahcf) · line 332
Quoted 6 lines
target/arm/kvm.c +6
-0+* returns is selected by CSSELR_EL1, so there is no single +* value to capture here. It is exposed to userspace only via +* the DEMUX API (KVM_REG_ARM_DEMUX_ID_CCSIDR), indexed by +* CSSELR. Skip reading it here as there is no meaningful host +* value to read. +*/ I think you should rely on prerequisite
[PATCH v4 3/3] arm/kvm: get demuxed ID registers from kvm
Currently I am just skipping those as anyway KVM exposes a very barebone Cache topology.
Agreed on using DEMUX regs, in case we want to support exopsing some other “config”.
Also on this point, I don’t know if CCSIDR_EL1/CCSIDR2_EL1 should be part of idregs[], we already have a ccsidr[], maybe this can be fixed in your series.
Quoted 20 lines
Quoted 10 lines
target/arm/kvm.c +10
-0+break ; +case SMIDR_EL1_IDX : +/* +* As SME is not yet supported by KVM, ignore reading SMIDR_EL1 +*/ +break ; +case GMID_EL1_IDX : +/* +* GMID_EL1 is not in KVM's sys_reg_descs[] and guest reads +* the raw host value. But as it is an EL1 register, we cannot target/arm/kvm.c static int get_host_cpu_idregs(int fd, ARMHostCPUFeatures *ahcf) · line 352
Quoted 10 lines
target/arm/kvm.c +10
-0+* read it directly. This is a genuine miss when MTE is +* enabled for the guest. +*/ +break ; +default : + ret =read_sys_reg64 (fd, reg,idregs_sysreg_to_kvm_reg (sysreg)); +if (ret) { +if (errno ==ENOENT ) { +warn_report ("%s error reading value of host %s register " +"(ENOENT)" , __func__, sysregdesc->name);
Quoted 1 line
trace point
Noted.
Warm Regards,
Khushit
Quoted 11 lines
target/arm/kvm.c static int get_host_cpu_idregs(int fd, ARMHostCPUFeatures *ahcf) · line 360
Quoted 8 lines
target/arm/kvm.c +5
-0+ }else { +error_report ("%s error reading value of host %s register" +" (%m)" , __func__, sysregdesc->name); + err = ret; + } } }trace_get_host_cpu_idregs (sysregdesc->name, *reg);Thanks
Eric
Re: [RFC PATCH v3 07/19] target/arm/kvm: handle special ID registers cases when reading from KVM
Quoted 75 lines · Khushit Shah
Quoted 64 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Hi Khushit,
Quoted 53 lines · Khushit Shah
The generic
KVM_GET_ONE_REGloop cannot correctly read a handful of ID registers, so specially handle those:-
DCZID_EL0: No fine grain trap exists, hence not tracked by KVM. It is EL0-readable and untrapped, so read it directly with MRS.- CCSIDR_EL1/CCSIDR2_EL1: not plain ID registers, their value is selected by
CSSELR_EL1. KVM only exposes them via the DEMUX API (KVM_REG_ARM_DEMUX_ID_CCSIDR), so there is no single value to read here. Skip them.-
SMIDR_EL1: KVM does not support SME, so there is no meaningful host value. Skip it.-
GMID_EL1: not in KVM's sys_reg_descs[] and, being an EL1 register, cannot be read from userspace via MRS either. The guest reads the raw host value; this is a genuine miss when MTE is enabled.Signed-off-by Khushit Shah <[email protected]>---
target/arm/kvm.c| 53 ++++++++++++++++++++++++++++++++++++++++--------1 file changed, 44 insertions(+), 9 deletions(-)target/arm/kvm.c +13
-9@@ -311,15 +311,50 @@ static int get_host_cpu_idregs(int fd, ARMHostCPUFeatures *ahcf)int ret; reg = &ahcf->isar.idregs[i]; - ret =read_sys_reg64 (fd, reg,idregs_sysreg_to_kvm_reg (sysreg)); -if (ret) { -if (errno ==ENOENT ) { -warn_report ("%s error reading value of host %s register " -"(ENOENT)" , __func__, sysregdesc->name); - }else { -error_report ("%s error reading value of host %s register" -" (%m)" , __func__, sysregdesc->name); - err = ret; +switch (i) { +case DCZID_EL0_IDX : +/* +* DCZID_EL0 is not in KVM's sys_reg_descs[], so +* KVM_GET_ONE_REG will fail. Read it directly from +* hardware since KVM doesn't trap guest reads of it. +*/ + asmvolatile ("mrs %0, DCZID_EL0" :"=r" (*reg)); +break ; +case CCSIDR_EL1_IDX : +case CCSIDR2_EL1_IDX : +/* +* CCSIDR_EL1 is not a plain ID register: the value it Quoted 8 lines
target/arm/kvm.c static int get_host_cpu_idregs(int fd, ARMHostCPUFeatures *ahcf) · line 332
Quoted 6 lines
target/arm/kvm.c +6
-0+* returns is selected by CSSELR_EL1, so there is no single +* value to capture here. It is exposed to userspace only via +* the DEMUX API (KVM_REG_ARM_DEMUX_ID_CCSIDR), indexed by +* CSSELR. Skip reading it here as there is no meaningful host +* value to read. +*/ I think you should rely on prerequisite
[PATCH v4 3/3] arm/kvm: get demuxed ID registers from kvmCurrently I am just skipping those as anyway KVM exposes a very barebone Cache topology.
Quoted 6 lines
Agreed on using DEMUX regs, in case we want to support exopsing some other “config”.
Also on this point, I don’t know if CCSIDR_EL1/CCSIDR2_EL1 should be part of idregs[], we already have a ccsidr[], maybe this can be fixed in your series.
OK i will investigate this.
Thanks
Eric
Quoted 38 lines
Quoted 21 lines
Quoted 11 lines
target/arm/kvm.c +10
-0+break ; +case SMIDR_EL1_IDX : +/* +* As SME is not yet supported by KVM, ignore reading SMIDR_EL1 +*/ +break ; +case GMID_EL1_IDX : +/* +* GMID_EL1 is not in KVM's sys_reg_descs[] and guest reads +* the raw host value. But as it is an EL1 register, we cannot target/arm/kvm.c static int get_host_cpu_idregs(int fd, ARMHostCPUFeatures *ahcf) · line 352
Quoted 10 lines
target/arm/kvm.c +10
-0+* read it directly. This is a genuine miss when MTE is +* enabled for the guest. +*/ +break ; +default : + ret =read_sys_reg64 (fd, reg,idregs_sysreg_to_kvm_reg (sysreg)); +if (ret) { +if (errno ==ENOENT ) { +warn_report ("%s error reading value of host %s register " +"(ENOENT)" , __func__, sysregdesc->name);Quoted 1 line
trace point
Noted.
Warm Regards,
KhushitQuoted 11 lines
target/arm/kvm.c static int get_host_cpu_idregs(int fd, ARMHostCPUFeatures *ahcf) · line 360
Quoted 8 lines
target/arm/kvm.c +5
-0+ }else { +error_report ("%s error reading value of host %s register" +" (%m)" , __func__, sysregdesc->name); + err = ret; + } } }trace_get_host_cpu_idregs (sysregdesc->name, *reg);Thanks
Eric
RFC PATCH v3 8/19 target/arm/kvm: Handle writeback for special ID register fields
In reply to Khushit ShahSome fields should not be written back to KVM for various reasons:
- ID_AA64PFR0_EL1.GIC / ID_PFR1_EL1.GIC are fabricated by KVM based on the gic-version property.
- KVM does not allow writing 0 to ID_DFR0_EL1.CopDbg, which breaks booting an AArch64-only guest on a host that also supports AArch32.
- ID_DFR0_EL1.PerfMon is populated by KVM even for AArch64-only guests but is not writable there.
- MPIDR_EL1 is managed by KVM based on vCPU index.
- Hold off writing back CLIDR_EL1 until we properly support exposing cache topology to a KVM guest.
Some registers such as DCZID_EL0 are not exposed through the KVM cpreg list at all, but guest still sees the host value, we verify that vCPU's ID regs values match the host value.
To do this, refactor kvm_arm_writable_idregs_to_cpreg_list to kvm_arm_write_idregs_to_cpregs_list, which operates per field and now returns an error if a non-writable field mismatches with the host value.
--- target/arm/cpu-idregs.c | 19 +++++++ target/arm/cpu-idregs.h | 4 ++ target/arm/kvm.c | 116 ++++++++++++++++++++++++++++++++++------ target/arm/trace-events | 2 +- 4 files changed, 125 insertions(+), 16 deletions(-)
target/arm/cpu-idregs.c +19 -0
@@ -7,6 +7,7 @@* SPDX-License-Identifier: GPL-2.0-or-later */ #include "qemu/osdep.h" +#include "qemu/bitops.h" #include "qemu/error-report.h" #include "qapi/error.h" #include "cpu.h"
@@ -94,3 +95,21 @@ ARM64SysReg arm64_id_regs[NUM_ID_IDX] = {#include "cpu-idregs.h.inc" }; +uint64_t arm_get_field_mask (const ARM64SysRegField *field) +{ +return MAKE_64BIT_MASK (field->shift, field->length); +} + +bool arm_field_is_writable (const ARM64SysRegField *field) +{ +uint64_t field_mask =arm_get_field_mask (field); + +return (arm64_id_regs[field->index].writable_mask & field_mask) + == field_mask; +} + +bool field_matches (const ARM64SysRegField *field,ARMIDRegisterIdx index, +const char *name) +{ +return field->index == index && !strcmp (field->name, name); +}
target/arm/cpu-idregs.h +4 -0
@@ -38,4 +38,8 @@ typedef struct ARM64SysReg {*/ extern ARM64SysReg arm64_id_regs[NUM_ID_IDX ]; +uint64_t arm_get_field_mask (const ARM64SysRegField *field); +bool arm_field_is_writable (const ARM64SysRegField *field); +bool field_matches (const ARM64SysRegField *field,ARMIDRegisterIdx index, +const char *name);#endif
target/arm/kvm.c +101 -15
147 lines not on this page · raw message
target/arm/trace-events +1 -1
@@ -14,7 +14,7 @@ arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d" # kvm.c kvm_arm_fixup_msi_route(uint64_t iova, uint64_t gpa) "MSI iova = 0x%"PRIx64" is translated into 0x%"PRIx64 get_host_cpu_idregs(const char *name, uint64_t value) "scratch vcpu host value for %s is 0x%"PRIx64 -kvm_arm_writable_idregs_to_cpreg_list(const char *name, uint64_t previous, uint64_t new) "%s overwrite default 0x%"PRIx64" with 0x%"PRIx64 +kvm_arm_write_idregs_to_cpreg_list(const char *name, uint64_t previous, uint64_t new) "%s overwrite default 0x%"PRIx64" with 0x%"PRIx64 # cpu64.c get_sysreg_prop(const char *name, uint64_t value) "%s 0x%"PRIx64
Signature · 1 line
2.52.0
Re: [RFC PATCH v3 08/19] target/arm/kvm: Handle writeback for special ID register fields
Hi Khushit,
Quoted 3 lines · Khushit Shah
Some fields should not be written back to KVM for various reasons:
- ID_AA64PFR0_EL1.GIC / ID_PFR1_EL1.GIC are fabricated by KVM based on the gic-version property.
so this is part of the overall handling of legacy composite options versus sysreg settings. To be the fact they both are consistent should be enforced upfront.
Quoted 7 lines
- KVM does not allow writing 0 to ID_DFR0_EL1.CopDbg, which breaks booting an AArch64-only guest on a host that also supports AArch32.
- ID_DFR0_EL1.PerfMon is populated by KVM even for AArch64-only guests but is not writable there.
-MPIDR_EL1is managed by KVM based on vCPU index.
- Hold off writing backCLIDR_EL1until we properly support exposing cache topology to a KVM guest.
Sounds this deserves a prerequisite fix. I also have this hack in my series but this should be dealt with separately I think.
Quoted 4 lines
Some registers such as
DCZID_EL0are not exposed through the KVM cpreg list at all, but guest still sees the host value, we verify that vCPU's ID regs values match the host value.
why isn't it cpreg then? Shouldn't we add it instead?
Quoted 36 lines
To do this, refactor
kvm_arm_writable_idregs_to_cpreg_listtokvm_arm_write_idregs_to_cpregs_list, which operates per field and now returns an error if a non-writable field mismatches with the host value.Signed-off-by Khushit Shah <[email protected]>--- target/arm/cpu-idregs.c | 19 +++++++ target/arm/cpu-idregs.h | 4 ++ target/arm/kvm.c | 116 ++++++++++++++++++++++++++++++++++------ target/arm/trace-events | 2 +- 4 files changed, 125 insertions(+), 16 deletions(-)target/arm/cpu-idregs.c +8
-0@@ -7,6 +7,7 @@* SPDX-License-Identifier: GPL-2.0-or-later */ #include "qemu/osdep.h" +#include "qemu/bitops.h" #include "qemu/error-report.h" #include "qapi/error.h" #include "cpu.h" @@ -94,3 +95,21 @@ ARM64SysReg arm64_id_regs[NUM_ID_IDX] = {#include "cpu-idregs.h.inc" }; +uint64_t arm_get_field_mask (const ARM64SysRegField *field) +{ +return MAKE_64BIT_MASK (field->shift, field->length); +} + +bool arm_field_is_writable (const ARM64SysRegField *field) +{
target/arm/cpu-idregs.c ARM64SysReg arm64_id_regs[NUM_ID_IDX] = { · line 114
Quoted 10 lines
target/arm/cpu-idregs.c +10
-0+uint64_t field_mask =arm_get_field_mask (field); + +return (arm64_id_regs[field->index].writable_mask & field_mask) + == field_mask; +} + +bool field_matches (const ARM64SysRegField *field,ARMIDRegisterIdx index, +const char *name) +{ +return field->index == index && !strcmp (field->name, name);
why do you need to check both index and name. Only checking index should be sufficient.
Quoted 92 lines
target/arm/cpu-idregs.c +1
-0+}target/arm/cpu-idregs.h +4
-0@@ -38,4 +38,8 @@ typedef struct ARM64SysReg {*/ extern ARM64SysReg arm64_id_regs[NUM_ID_IDX ]; +uint64_t arm_get_field_mask (const ARM64SysRegField *field); +bool arm_field_is_writable (const ARM64SysRegField *field); +bool field_matches (const ARM64SysRegField *field,ARMIDRegisterIdx index, +const char *name);#endif target/arm/kvm.c +50
-5@@ -951,6 +951,16 @@ static uint64_t *kvm_arm_get_cpreg_ptr(ARMCPU *cpu, uint64_t regidx)return &cpu->cpreg_values[res - cpu->cpreg_indexes]; } +/* Like kvm_arm_get_cpreg_ptr, but returns NULL if the register is not found. */ +static uint64_t *kvm_arm_find_cpreg_ptr (ARMCPU *cpu,uint64_t regidx) +{ +uint64_t *res; + res =bsearch (®idx, cpu->cpreg_indexes, cpu->cpreg_array_len, +sizeof (uint64_t ), compare_u64); + +return res ? &cpu->cpreg_values[res - cpu->cpreg_indexes] :NULL ; +} +/** * kvm_arm_reg_syncs_via_cpreg_list: * @regidx: KVM register index @@ -1252,32 +1262,105 @@ bool kvm_arm_cpu_post_load(ARMCPU *cpu)return true; } +static bool arm_field_skip_writeback_always (const ARM64SysRegField *field) +{ +/* +* GIC is controlled by the gic-version property and fabricated by KVM +* when the vGIC device is created, so a named CPU model must not touch +* it. KVM also rejects writing 0 to ID_DFR0_EL1.CopDbg, which breaks +* booting a model that lacks AArch32 support on a host that supports +* it. MPIDR_EL1 is managed by KVM based on number of vCPUs, skip +* writing it back. Similarly, skip writing back CLIDR_EL1 till we +* properly support exposing cache for KVM guest. +*/ +return field_matches (field,ID_AA64PFR0_EL1_IDX ,"GIC" ) + ||field_matches (field,ID_PFR1_EL1_IDX ,"GIC" ) + ||field_matches (field,ID_DFR0_EL1_IDX ,"CopDbg" ) + || field->index ==MPIDR_EL1_IDX + || field->index ==CLIDR_EL1_IDX ; +} + +static bool arm_field_skip_writeback_if_not_writable (const ARM64SysRegField *field) +{ +/* +* KVM populates ID_DFR0_EL1.PerfMon even for AArch64-only guests but +* does not expose it as writable there, so skip it when it is not +* writable. +*/ +return field_matches (field,ID_DFR0_EL1_IDX ,"PerfMon" ); +} +/* -* Copy writable ID regs from isar.idregs[] to cpreg_list -* in case their value differs from the original init cpreg value +* Copy writable ID reg fields from isar.idregs[] into the KVM cpreg list, +* so the subsequent write_list_to_kvmstate() pushes them to KVM. +* Only writable fields are copied; fields that must not be written back +* (see arm_field_skip_writeback_*) are skipped. +* Returns -1 if any vCPU's ID reg value differs from the host value and the +* field is not writable. */ -static void kvm_arm_writable_idregs_to_cpreg_list (ARMCPU *cpu) +static int kvm_arm_write_idregs_to_cpreg_list (ARMCPU *cpu) {for (int i =0 ; i <NUM_ID_IDX ; i++) {ARM64SysReg *sysregdesc = &arm64_id_regs[i];ARMSysRegs sysreg = id_register_sysreg[i]; -uint64_t previous, new; +uint64_t writable_mask = sysregdesc->writable_mask; +uint64_t desired = cpu->isar.idregs[i]; +uint64_t previous, updated;uint64_t *cpreg; -if (!sysregdesc->writable_mask) { + cpreg =kvm_arm_find_cpreg_ptr (cpu,idregs_sysreg_to_kvm_reg (sysreg)); +/*
target/arm/kvm.c bool kvm_arm_cpu_post_load(ARMCPU *cpu) · line 1322
Quoted 10 lines
target/arm/kvm.c +8
-0+* Registers such as DCZID_EL0 are not exposed through the cpreg +* list and are therefore not writable. Use the host value +* snapshotted at probe time as the reference to check the vCPU ID +* regs have the same value. +*/ + previous = cpreg ? *cpreg : arm_host_cpu_features.isar.idregs[i]; + +if (previous == desired) {continue ; }
while at it you could also test all reserved fields here, RAZ, RES0/1 and make sure host value complies with the description.
Quoted 71 lines
target/arm/kvm.c +43
-10- cpreg =kvm_arm_get_cpreg_ptr (cpu,idregs_sysreg_to_kvm_reg (sysreg)); - previous = *cpreg; - new = cpu->isar.idregs[i]; +for (int j =0 ; j < sysregdesc->fields_count; j++) { +const ARM64SysRegField *field = &sysregdesc->fields[j]; +uint64_t field_mask =arm_get_field_mask (field); +uint64_t prev_val = previous & field_mask; +uint64_t new_val = desired & field_mask; + +if (prev_val == new_val) { +continue ; + } + +if (arm_field_skip_writeback_always (field) || + (!arm_field_is_writable (field) && +arm_field_skip_writeback_if_not_writable (field))) { +/* Never write this field back; keep KVM's value. */ + writable_mask &= ~field_mask; +continue ; + } + +if (!arm_field_is_writable (field)) { +error_report ("%s.%s is not writable: host=0x%" PRIx64 +", requested=0x%" PRIx64, + sysregdesc->name, field->name, + prev_val >> field->shift, new_val >> field->shift); +return -1 ; + } + } + +if (!cpreg || !writable_mask) { +continue ; + } -if (previous != new) { - *cpreg = new; -trace_kvm_arm_writable_idregs_to_cpreg_list (sysregdesc->name, - previous, new); - } + updated = (previous & ~writable_mask) | (desired & writable_mask); +if (updated != previous) { + *cpreg = updated; +trace_kvm_arm_write_idregs_to_cpreg_list (sysregdesc->name, + previous, updated); + } } + +return 0 ; }void kvm_arm_reset_vcpu (ARMCPU *cpu)@@ -2235,8 +2318,11 @@ int kvm_arch_init_vcpu(CPUState *cs)if (ret) {return ret; } -/* overwrite writable ID regs with their updated property values */ -kvm_arm_writable_idregs_to_cpreg_list (cpu); +/* overwrite ID reg fields with their updated property values */ + ret =kvm_arm_write_idregs_to_cpreg_list (cpu); +if (ret) { +return ret; + } ret =write_list_to_kvmstate (cpu,KVM_PUT_FULL_STATE );if (!ret) {return -1 ;target/arm/trace-events +0
-0
target/arm/trace-events arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d" · line 20
Quoted 8 lines
target/arm/trace-events +1
-1@@ -14,7 +14,7 @@ arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d" # kvm.c kvm_arm_fixup_msi_route(uint64_t iova, uint64_t gpa) "MSI iova = 0x%"PRIx64" is translated into 0x%"PRIx64 get_host_cpu_idregs(const char *name, uint64_t value) "scratch vcpu host value for %s is 0x%"PRIx64 -kvm_arm_writable_idregs_to_cpreg_list(const char *name, uint64_t previous, uint64_t new) "%s overwrite default 0x%"PRIx64" with 0x%"PRIx64 +kvm_arm_write_idregs_to_cpreg_list(const char *name, uint64_t previous, uint64_t new) "%s overwrite default 0x%"PRIx64" with 0x%"PRIx64 # cpu64.c get_sysreg_prop(const char *name, uint64_t value) "%s 0x%"PRIx64
Thanks
Eric
Re: [RFC PATCH v3 08/19] target/arm/kvm: Handle writeback for special ID register fields
Quoted 62 lines · Eric Auger
Hi Khushit,
Quoted 3 lines · Khushit Shah
Some fields should not be written back to KVM for various reasons:
- ID_AA64PFR0_EL1.GIC / ID_PFR1_EL1.GIC are fabricated by KVM based on the gic-version property.so this is part of the overall handling of legacy composite options versus sysreg settings. To be the fact they both are consistent should be enforced upfront.
Quoted 7 lines
- KVM does not allow writing 0 to ID_DFR0_EL1.CopDbg, which breaks booting an AArch64-only guest on a host that also supports AArch32.
- ID_DFR0_EL1.PerfMon is populated by KVM even for AArch64-only guests but is not writable there.
-MPIDR_EL1is managed by KVM based on vCPU index.
- Hold off writing backCLIDR_EL1until we properly support exposing cache topology to a KVM guest.Sounds this deserves a prerequisite fix. I also have this hack in my series but this should be dealt with separately I think.
Quoted 4 lines
Some registers such as
DCZID_EL0are not exposed through the KVM cpreg list at all, but guest still sees the host value, we verify that vCPU's ID regs values match the host value.why isn't it cpreg then? Shouldn't we add it instead?
Quoted 40 lines
To do this, refactor
kvm_arm_writable_idregs_to_cpreg_listtokvm_arm_write_idregs_to_cpregs_list, which operates per field and now returns an error if a non-writable field mismatches with the host value.Signed-off-by Khushit Shah <[email protected]>--- target/arm/cpu-idregs.c | 19 +++++++ target/arm/cpu-idregs.h | 4 ++ target/arm/kvm.c | 116 ++++++++++++++++++++++++++++++++++------ target/arm/trace-events | 2 +- 4 files changed, 125 insertions(+), 16 deletions(-)target/arm/cpu-idregs.c +12
-0@@ -7,6 +7,7 @@* SPDX-License-Identifier: GPL-2.0-or-later */ #include "qemu/osdep.h" +#include "qemu/bitops.h" #include "qemu/error-report.h" #include "qapi/error.h" #include "cpu.h" @@ -94,3 +95,21 @@ ARM64SysReg arm64_id_regs[NUM_ID_IDX] = {#include "cpu-idregs.h.inc" }; +uint64_t arm_get_field_mask (const ARM64SysRegField *field) +{ +return MAKE_64BIT_MASK (field->shift, field->length); +} + +bool arm_field_is_writable (const ARM64SysRegField *field) +{ +uint64_t field_mask =arm_get_field_mask (field); + +return (arm64_id_regs[field->index].writable_mask & field_mask) + == field_mask;
Quoted 8 lines
target/arm/cpu-idregs.c ARM64SysReg arm64_id_regs[NUM_ID_IDX] = { · line 114
Quoted 6 lines
target/arm/cpu-idregs.c +6
-0+} + +bool field_matches (const ARM64SysRegField *field,ARMIDRegisterIdx index, +const char *name) +{ +return field->index == index && !strcmp (field->name, name);why do you need to check both index and name. Only checking index should be sufficient.
forget this, index refers to the reg while name corresponds to the field name. Thought name was the prop name ...
Eric
Quoted 186 lines
Quoted 92 lines
target/arm/cpu-idregs.c +1
-0+}target/arm/cpu-idregs.h +4
-0@@ -38,4 +38,8 @@ typedef struct ARM64SysReg {*/ extern ARM64SysReg arm64_id_regs[NUM_ID_IDX ]; +uint64_t arm_get_field_mask (const ARM64SysRegField *field); +bool arm_field_is_writable (const ARM64SysRegField *field); +bool field_matches (const ARM64SysRegField *field,ARMIDRegisterIdx index, +const char *name);#endif target/arm/kvm.c +50
-5@@ -951,6 +951,16 @@ static uint64_t *kvm_arm_get_cpreg_ptr(ARMCPU *cpu, uint64_t regidx)return &cpu->cpreg_values[res - cpu->cpreg_indexes]; } +/* Like kvm_arm_get_cpreg_ptr, but returns NULL if the register is not found. */ +static uint64_t *kvm_arm_find_cpreg_ptr (ARMCPU *cpu,uint64_t regidx) +{ +uint64_t *res; + res =bsearch (®idx, cpu->cpreg_indexes, cpu->cpreg_array_len, +sizeof (uint64_t ), compare_u64); + +return res ? &cpu->cpreg_values[res - cpu->cpreg_indexes] :NULL ; +} +/** * kvm_arm_reg_syncs_via_cpreg_list: * @regidx: KVM register index @@ -1252,32 +1262,105 @@ bool kvm_arm_cpu_post_load(ARMCPU *cpu)return true; } +static bool arm_field_skip_writeback_always (const ARM64SysRegField *field) +{ +/* +* GIC is controlled by the gic-version property and fabricated by KVM +* when the vGIC device is created, so a named CPU model must not touch +* it. KVM also rejects writing 0 to ID_DFR0_EL1.CopDbg, which breaks +* booting a model that lacks AArch32 support on a host that supports +* it. MPIDR_EL1 is managed by KVM based on number of vCPUs, skip +* writing it back. Similarly, skip writing back CLIDR_EL1 till we +* properly support exposing cache for KVM guest. +*/ +return field_matches (field,ID_AA64PFR0_EL1_IDX ,"GIC" ) + ||field_matches (field,ID_PFR1_EL1_IDX ,"GIC" ) + ||field_matches (field,ID_DFR0_EL1_IDX ,"CopDbg" ) + || field->index ==MPIDR_EL1_IDX + || field->index ==CLIDR_EL1_IDX ; +} + +static bool arm_field_skip_writeback_if_not_writable (const ARM64SysRegField *field) +{ +/* +* KVM populates ID_DFR0_EL1.PerfMon even for AArch64-only guests but +* does not expose it as writable there, so skip it when it is not +* writable. +*/ +return field_matches (field,ID_DFR0_EL1_IDX ,"PerfMon" ); +} +/* -* Copy writable ID regs from isar.idregs[] to cpreg_list -* in case their value differs from the original init cpreg value +* Copy writable ID reg fields from isar.idregs[] into the KVM cpreg list, +* so the subsequent write_list_to_kvmstate() pushes them to KVM. +* Only writable fields are copied; fields that must not be written back +* (see arm_field_skip_writeback_*) are skipped. +* Returns -1 if any vCPU's ID reg value differs from the host value and the +* field is not writable. */ -static void kvm_arm_writable_idregs_to_cpreg_list (ARMCPU *cpu) +static int kvm_arm_write_idregs_to_cpreg_list (ARMCPU *cpu) {for (int i =0 ; i <NUM_ID_IDX ; i++) {ARM64SysReg *sysregdesc = &arm64_id_regs[i];ARMSysRegs sysreg = id_register_sysreg[i]; -uint64_t previous, new; +uint64_t writable_mask = sysregdesc->writable_mask; +uint64_t desired = cpu->isar.idregs[i]; +uint64_t previous, updated;uint64_t *cpreg; -if (!sysregdesc->writable_mask) { + cpreg =kvm_arm_find_cpreg_ptr (cpu,idregs_sysreg_to_kvm_reg (sysreg)); +/* target/arm/kvm.c bool kvm_arm_cpu_post_load(ARMCPU *cpu) · line 1322
Quoted 10 lines
target/arm/kvm.c +8
-0+* Registers such as DCZID_EL0 are not exposed through the cpreg +* list and are therefore not writable. Use the host value +* snapshotted at probe time as the reference to check the vCPU ID +* regs have the same value. +*/ + previous = cpreg ? *cpreg : arm_host_cpu_features.isar.idregs[i]; + +if (previous == desired) {continue ; }while at it you could also test all reserved fields here, RAZ, RES0/1 and make sure host value complies with the description.
Quoted 71 lines
target/arm/kvm.c +43
-10- cpreg =kvm_arm_get_cpreg_ptr (cpu,idregs_sysreg_to_kvm_reg (sysreg)); - previous = *cpreg; - new = cpu->isar.idregs[i]; +for (int j =0 ; j < sysregdesc->fields_count; j++) { +const ARM64SysRegField *field = &sysregdesc->fields[j]; +uint64_t field_mask =arm_get_field_mask (field); +uint64_t prev_val = previous & field_mask; +uint64_t new_val = desired & field_mask; + +if (prev_val == new_val) { +continue ; + } + +if (arm_field_skip_writeback_always (field) || + (!arm_field_is_writable (field) && +arm_field_skip_writeback_if_not_writable (field))) { +/* Never write this field back; keep KVM's value. */ + writable_mask &= ~field_mask; +continue ; + } + +if (!arm_field_is_writable (field)) { +error_report ("%s.%s is not writable: host=0x%" PRIx64 +", requested=0x%" PRIx64, + sysregdesc->name, field->name, + prev_val >> field->shift, new_val >> field->shift); +return -1 ; + } + } + +if (!cpreg || !writable_mask) { +continue ; + } -if (previous != new) { - *cpreg = new; -trace_kvm_arm_writable_idregs_to_cpreg_list (sysregdesc->name, - previous, new); - } + updated = (previous & ~writable_mask) | (desired & writable_mask); +if (updated != previous) { + *cpreg = updated; +trace_kvm_arm_write_idregs_to_cpreg_list (sysregdesc->name, + previous, updated); + } } + +return 0 ; }void kvm_arm_reset_vcpu (ARMCPU *cpu)@@ -2235,8 +2318,11 @@ int kvm_arch_init_vcpu(CPUState *cs)if (ret) {return ret; } -/* overwrite writable ID regs with their updated property values */ -kvm_arm_writable_idregs_to_cpreg_list (cpu); +/* overwrite ID reg fields with their updated property values */ + ret =kvm_arm_write_idregs_to_cpreg_list (cpu); +if (ret) { +return ret; + } ret =write_list_to_kvmstate (cpu,KVM_PUT_FULL_STATE );if (!ret) {return -1 ;target/arm/trace-events +0
-0target/arm/trace-events arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d" · line 20
Quoted 8 lines
target/arm/trace-events +1
-1@@ -14,7 +14,7 @@ arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d" # kvm.c kvm_arm_fixup_msi_route(uint64_t iova, uint64_t gpa) "MSI iova = 0x%"PRIx64" is translated into 0x%"PRIx64 get_host_cpu_idregs(const char *name, uint64_t value) "scratch vcpu host value for %s is 0x%"PRIx64 -kvm_arm_writable_idregs_to_cpreg_list(const char *name, uint64_t previous, uint64_t new) "%s overwrite default 0x%"PRIx64" with 0x%"PRIx64 +kvm_arm_write_idregs_to_cpreg_list(const char *name, uint64_t previous, uint64_t new) "%s overwrite default 0x%"PRIx64" with 0x%"PRIx64 # cpu64.c get_sysreg_prop(const char *name, uint64_t value) "%s 0x%"PRIx64Thanks
Eric
Re: [RFC PATCH v3 08/19] target/arm/kvm: Handle writeback for special ID register fields
In reply to Eric AugerQuoted 9 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 8 lines
Hi Khushit,
Quoted 3 lines · Khushit Shah
Some fields should not be written back to KVM for various reasons:
- ID_AA64PFR0_EL1.GIC / ID_PFR1_EL1.GIC are fabricated by KVM based on the gic-version property.so this is part of the overall handling of legacy composite options versus sysreg settings. To be the fact they both are consistent should be enforced upfront.
I have one idea on how to handle this:
- After we finalise cpu features, we recheck each command line prop passed. The final idregs[]’s prop value should be same as the user provided one from the cmdline.
For e.g., invalid configurations like:
-cpu host,sve=on,SYSREG_ID_AA64PFR0_EL1_SVE=0
Or
-cpu host,pauth=off,SYSREG_ID_AA64ISAR1_EL1_APA=2
will be caught after finalise as both of those cannot be true at the same time.
If this makes sense, I can implement it for v4.
Quoted 7 lines
Quoted 7 lines
- KVM does not allow writing 0 to ID_DFR0_EL1.CopDbg, which breaks booting an AArch64-only guest on a host that also supports AArch32.
- ID_DFR0_EL1.PerfMon is populated by KVM even for AArch64-only guests but is not writable there.
-MPIDR_EL1is managed by KVM based on vCPU index.
- Hold off writing backCLIDR_EL1until we properly support exposing cache topology to a KVM guest.
Quoted 7 lines
Sounds this deserves a prerequisite fix. I also have this hack in my series but this should be dealt with separately I think.
Quoted 4 lines
Some registers such as
DCZID_EL0are not exposed through the KVM cpreg list at all, but guest still sees the host value, we verify that vCPU's ID regs values match the host value.why isn't it cpreg then? Shouldn't we add it instead?
idk why KVM does not expose DCZID_EL0.
Quoted 40 lines
Quoted 40 lines
To do this, refactor
kvm_arm_writable_idregs_to_cpreg_listtokvm_arm_write_idregs_to_cpregs_list, which operates per field and now returns an error if a non-writable field mismatches with the host value.Signed-off-by Khushit Shah <[email protected]>---
target/arm/cpu-idregs.c | 19 +++++++ target/arm/cpu-idregs.h | 4 ++ target/arm/kvm.c | 116 ++++++++++++++++++++++++++++++++++------ target/arm/trace-events | 2 +- 4 files changed, 125 insertions(+), 16 deletions(-)target/arm/cpu-idregs.c +12
-0@@ -7,6 +7,7 @@* SPDX-License-Identifier: GPL-2.0-or-later */ #include "qemu/osdep.h" +#include "qemu/bitops.h" #include "qemu/error-report.h" #include "qapi/error.h" #include "cpu.h" @@ -94,3 +95,21 @@ ARM64SysReg arm64_id_regs[NUM_ID_IDX] = {#include "cpu-idregs.h.inc" }; +uint64_t arm_get_field_mask (const ARM64SysRegField *field) +{ +return MAKE_64BIT_MASK (field->shift, field->length); +} + +bool arm_field_is_writable (const ARM64SysRegField *field) +{ +uint64_t field_mask =arm_get_field_mask (field); + +return (arm64_id_regs[field->index].writable_mask & field_mask) + == field_mask;
Quoted 8 lines
target/arm/cpu-idregs.c ARM64SysReg arm64_id_regs[NUM_ID_IDX] = { · line 114
Quoted 6 lines
target/arm/cpu-idregs.c +6
-0+} + +bool field_matches (const ARM64SysRegField *field,ARMIDRegisterIdx index, +const char *name) +{ +return field->index == index && !strcmp (field->name, name);why do you need to check both index and name. Only checking index should be sufficient.
Index gives register, name is field name.
Quoted 89 lines
Quoted 89 lines
target/arm/cpu-idregs.c +1
-0+}target/arm/cpu-idregs.h +4
-0@@ -38,4 +38,8 @@ typedef struct ARM64SysReg {*/ extern ARM64SysReg arm64_id_regs[NUM_ID_IDX ]; +uint64_t arm_get_field_mask (const ARM64SysRegField *field); +bool arm_field_is_writable (const ARM64SysRegField *field); +bool field_matches (const ARM64SysRegField *field,ARMIDRegisterIdx index, +const char *name);#endif target/arm/kvm.c +48
-4@@ -951,6 +951,16 @@ static uint64_t *kvm_arm_get_cpreg_ptr(ARMCPU *cpu, uint64_t regidx)return &cpu->cpreg_values[res - cpu->cpreg_indexes]; } +/* Like kvm_arm_get_cpreg_ptr, but returns NULL if the register is not found. */ +static uint64_t *kvm_arm_find_cpreg_ptr (ARMCPU *cpu,uint64_t regidx) +{ +uint64_t *res; + res =bsearch (®idx, cpu->cpreg_indexes, cpu->cpreg_array_len, +sizeof (uint64_t ), compare_u64); + +return res ? &cpu->cpreg_values[res - cpu->cpreg_indexes] :NULL ; +} +/** * kvm_arm_reg_syncs_via_cpreg_list: * @regidx: KVM register index @@ -1252,32 +1262,105 @@ bool kvm_arm_cpu_post_load(ARMCPU *cpu)return true; } +static bool arm_field_skip_writeback_always (const ARM64SysRegField *field) +{ +/* +* GIC is controlled by the gic-version property and fabricated by KVM +* when the vGIC device is created, so a named CPU model must not touch +* it. KVM also rejects writing 0 to ID_DFR0_EL1.CopDbg, which breaks +* booting a model that lacks AArch32 support on a host that supports +* it. MPIDR_EL1 is managed by KVM based on number of vCPUs, skip +* writing it back. Similarly, skip writing back CLIDR_EL1 till we +* properly support exposing cache for KVM guest. +*/ +return field_matches (field,ID_AA64PFR0_EL1_IDX ,"GIC" ) + ||field_matches (field,ID_PFR1_EL1_IDX ,"GIC" ) + ||field_matches (field,ID_DFR0_EL1_IDX ,"CopDbg" ) + || field->index ==MPIDR_EL1_IDX + || field->index ==CLIDR_EL1_IDX ; +} + +static bool arm_field_skip_writeback_if_not_writable (const ARM64SysRegField *field) +{ +/* +* KVM populates ID_DFR0_EL1.PerfMon even for AArch64-only guests but +* does not expose it as writable there, so skip it when it is not +* writable. +*/ +return field_matches (field,ID_DFR0_EL1_IDX ,"PerfMon" ); +} +/* -* Copy writable ID regs from isar.idregs[] to cpreg_list -* in case their value differs from the original init cpreg value +* Copy writable ID reg fields from isar.idregs[] into the KVM cpreg list, +* so the subsequent write_list_to_kvmstate() pushes them to KVM. +* Only writable fields are copied; fields that must not be written back +* (see arm_field_skip_writeback_*) are skipped. +* Returns -1 if any vCPU's ID reg value differs from the host value and the +* field is not writable. */ -static void kvm_arm_writable_idregs_to_cpreg_list (ARMCPU *cpu) +static int kvm_arm_write_idregs_to_cpreg_list (ARMCPU *cpu) {for (int i =0 ; i <NUM_ID_IDX ; i++) {ARM64SysReg *sysregdesc = &arm64_id_regs[i];ARMSysRegs sysreg = id_register_sysreg[i]; -uint64_t previous, new; +uint64_t writable_mask = sysregdesc->writable_mask; +uint64_t desired = cpu->isar.idregs[i]; +uint64_t previous, updated;uint64_t *cpreg;
Quoted 15 lines
target/arm/kvm.c bool kvm_arm_cpu_post_load(ARMCPU *cpu) · line 1322
Quoted 13 lines
target/arm/kvm.c +10
-1-if (!sysregdesc->writable_mask) { + cpreg =kvm_arm_find_cpreg_ptr (cpu,idregs_sysreg_to_kvm_reg (sysreg)); +/* +* Registers such as DCZID_EL0 are not exposed through the cpreg +* list and are therefore not writable. Use the host value +* snapshotted at probe time as the reference to check the vCPU ID +* regs have the same value. +*/ + previous = cpreg ? *cpreg : arm_host_cpu_features.isar.idregs[i]; + +if (previous == desired) {continue ; }while at it you could also test all reserved fields here, RAZ, RES0/1 and make sure host value complies with the description.
Noted, will add it in v4
Warm Regards,
Khushit
Quoted 82 lines
Quoted 77 lines
target/arm/kvm.c +43
-10- cpreg =kvm_arm_get_cpreg_ptr (cpu,idregs_sysreg_to_kvm_reg (sysreg)); - previous = *cpreg; - new = cpu->isar.idregs[i]; +for (int j =0 ; j < sysregdesc->fields_count; j++) { +const ARM64SysRegField *field = &sysregdesc->fields[j]; +uint64_t field_mask =arm_get_field_mask (field); +uint64_t prev_val = previous & field_mask; +uint64_t new_val = desired & field_mask; + +if (prev_val == new_val) { +continue ; + } + +if (arm_field_skip_writeback_always (field) || + (!arm_field_is_writable (field) && +arm_field_skip_writeback_if_not_writable (field))) { +/* Never write this field back; keep KVM's value. */ + writable_mask &= ~field_mask; +continue ; + } + +if (!arm_field_is_writable (field)) { +error_report ("%s.%s is not writable: host=0x%" PRIx64 +", requested=0x%" PRIx64, + sysregdesc->name, field->name, + prev_val >> field->shift, new_val >> field->shift); +return -1 ; + } + } + +if (!cpreg || !writable_mask) { +continue ; + } -if (previous != new) { - *cpreg = new; -trace_kvm_arm_writable_idregs_to_cpreg_list (sysregdesc->name, - previous, new); - } + updated = (previous & ~writable_mask) | (desired & writable_mask); +if (updated != previous) { + *cpreg = updated; +trace_kvm_arm_write_idregs_to_cpreg_list (sysregdesc->name, + previous, updated); + } } + +return 0 ; }void kvm_arm_reset_vcpu (ARMCPU *cpu)@@ -2235,8 +2318,11 @@ int kvm_arch_init_vcpu(CPUState *cs)if (ret) {return ret; } -/* overwrite writable ID regs with their updated property values */ -kvm_arm_writable_idregs_to_cpreg_list (cpu); +/* overwrite ID reg fields with their updated property values */ + ret =kvm_arm_write_idregs_to_cpreg_list (cpu); +if (ret) { +return ret; + } ret =write_list_to_kvmstate (cpu,KVM_PUT_FULL_STATE );if (!ret) {return -1 ;target/arm/trace-events +0
-0@@ -14,7 +14,7 @@ arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d" # kvm.c
kvm_arm_fixup_msi_route(uint64_t iova, uint64_t gpa)"MSI iova = 0x%"PRIx64" is translated into 0x%"PRIx64get_host_cpu_idregs(const char *name, uint64_t value)"scratch vcpu host value for %s is 0x%"PRIx64target/arm/trace-events +1
-1-kvm_arm_writable_idregs_to_cpreg_list(const char *name, uint64_t previous, uint64_t new) "%s overwrite default 0x%"PRIx64" with 0x%"PRIx64 +kvm_arm_write_idregs_to_cpreg_list(const char *name, uint64_t previous, uint64_t new) "%s overwrite default 0x%"PRIx64" with 0x%"PRIx64Quoted 2 lines
# cpu64.c get_sysreg_prop(const char *name, uint64_t value) "%s 0x%"PRIx64Thanks
Eric
Re: [RFC PATCH v3 08/19] target/arm/kvm: Handle writeback for special ID register fields
Hi Khushit,
Quoted 25 lines · Khushit Shah
Quoted 8 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 8 lines
Hi Khushit,
Quoted 3 lines · Khushit Shah
Some fields should not be written back to KVM for various reasons:
- ID_AA64PFR0_EL1.GIC / ID_PFR1_EL1.GIC are fabricated by KVM based on the gic-version property.so this is part of the overall handling of legacy composite options versus sysreg settings. To be the fact they both are consistent should be enforced upfront.
I have one idea on how to handle this:
- After we finalise cpu features, we recheck each command line prop passed. The final idregs[]’s prop value should be same as the user provided one from the cmdline.
For e.g., invalid configurations like:
-cpu host,sve=on,SYSREG_ID_AA64PFR0_EL1_SVE=0
Or
-cpu host,pauth=off,SYSREG_ID_AA64ISAR1_EL1_APA=2
Quoted 4 lines
will be caught after finalise as both of those cannot be true at the same time.
If this makes sense, I can implement it for v4.
Yes consistency checking between low level props and legacy composite props is one of the next topic to be addressed on the prerequisite series. I think the next one is to improve the scratch vcpu dry run
in qmp_query_cpu_model_expansion which is not precise enough (it applies low level settings on a scratch vcpu whose init struct is based on some host assumptions rather than comprehensive property settings, this should be refined). If you want to work on this consistency checking problematic, feel free. Otherwise I will.
Thanks
Eric
Quoted 255 lines
Quoted 8 lines
Quoted 8 lines
- KVM does not allow writing 0 to ID_DFR0_EL1.CopDbg, which breaks booting an AArch64-only guest on a host that also supports AArch32.
- ID_DFR0_EL1.PerfMon is populated by KVM even for AArch64-only guests but is not writable there.
-MPIDR_EL1is managed by KVM based on vCPU index.
- Hold off writing backCLIDR_EL1until we properly support exposing cache topology to a KVM guest.Quoted 6 lines
Sounds this deserves a prerequisite fix. I also have this hack in my series but this should be dealt with separately I think.
Quoted 3 lines
Some registers such as
DCZID_EL0are not exposed through the KVM cpreg list at all, but guest still sees the host value, we verify that vCPU's ID regs values match the host value.why isn't it cpreg then? Shouldn't we add it instead?
idk why KVM does not expose
DCZID_EL0.Quoted 39 lines
Quoted 39 lines
To do this, refactor
kvm_arm_writable_idregs_to_cpreg_listtokvm_arm_write_idregs_to_cpregs_list, which operates per field and now returns an error if a non-writable field mismatches with the host value.Signed-off-by Khushit Shah <[email protected]>---
target/arm/cpu-idregs.c | 19 +++++++ target/arm/cpu-idregs.h | 4 ++ target/arm/kvm.c | 116 ++++++++++++++++++++++++++++++++++------ target/arm/trace-events | 2 +- 4 files changed, 125 insertions(+), 16 deletions(-)target/arm/cpu-idregs.c +12
-0@@ -7,6 +7,7 @@* SPDX-License-Identifier: GPL-2.0-or-later */ #include "qemu/osdep.h" +#include "qemu/bitops.h" #include "qemu/error-report.h" #include "qapi/error.h" #include "cpu.h" @@ -94,3 +95,21 @@ ARM64SysReg arm64_id_regs[NUM_ID_IDX] = {#include "cpu-idregs.h.inc" }; +uint64_t arm_get_field_mask (const ARM64SysRegField *field) +{ +return MAKE_64BIT_MASK (field->shift, field->length); +} + +bool arm_field_is_writable (const ARM64SysRegField *field) +{ +uint64_t field_mask =arm_get_field_mask (field); + +return (arm64_id_regs[field->index].writable_mask & field_mask) + == field_mask;Quoted 8 lines
target/arm/cpu-idregs.c ARM64SysReg arm64_id_regs[NUM_ID_IDX] = { · line 114
Quoted 6 lines
target/arm/cpu-idregs.c +6
-0+} + +bool field_matches (const ARM64SysRegField *field,ARMIDRegisterIdx index, +const char *name) +{ +return field->index == index && !strcmp (field->name, name);why do you need to check both index and name. Only checking index should be sufficient.
Index gives register, name is field name.
Quoted 89 lines
Quoted 89 lines
target/arm/cpu-idregs.c +1
-0+}target/arm/cpu-idregs.h +4
-0@@ -38,4 +38,8 @@ typedef struct ARM64SysReg {*/ extern ARM64SysReg arm64_id_regs[NUM_ID_IDX ]; +uint64_t arm_get_field_mask (const ARM64SysRegField *field); +bool arm_field_is_writable (const ARM64SysRegField *field); +bool field_matches (const ARM64SysRegField *field,ARMIDRegisterIdx index, +const char *name);#endif target/arm/kvm.c +48
-4@@ -951,6 +951,16 @@ static uint64_t *kvm_arm_get_cpreg_ptr(ARMCPU *cpu, uint64_t regidx)return &cpu->cpreg_values[res - cpu->cpreg_indexes]; } +/* Like kvm_arm_get_cpreg_ptr, but returns NULL if the register is not found. */ +static uint64_t *kvm_arm_find_cpreg_ptr (ARMCPU *cpu,uint64_t regidx) +{ +uint64_t *res; + res =bsearch (®idx, cpu->cpreg_indexes, cpu->cpreg_array_len, +sizeof (uint64_t ), compare_u64); + +return res ? &cpu->cpreg_values[res - cpu->cpreg_indexes] :NULL ; +} +/** * kvm_arm_reg_syncs_via_cpreg_list: * @regidx: KVM register index @@ -1252,32 +1262,105 @@ bool kvm_arm_cpu_post_load(ARMCPU *cpu)return true; } +static bool arm_field_skip_writeback_always (const ARM64SysRegField *field) +{ +/* +* GIC is controlled by the gic-version property and fabricated by KVM +* when the vGIC device is created, so a named CPU model must not touch +* it. KVM also rejects writing 0 to ID_DFR0_EL1.CopDbg, which breaks +* booting a model that lacks AArch32 support on a host that supports +* it. MPIDR_EL1 is managed by KVM based on number of vCPUs, skip +* writing it back. Similarly, skip writing back CLIDR_EL1 till we +* properly support exposing cache for KVM guest. +*/ +return field_matches (field,ID_AA64PFR0_EL1_IDX ,"GIC" ) + ||field_matches (field,ID_PFR1_EL1_IDX ,"GIC" ) + ||field_matches (field,ID_DFR0_EL1_IDX ,"CopDbg" ) + || field->index ==MPIDR_EL1_IDX + || field->index ==CLIDR_EL1_IDX ; +} + +static bool arm_field_skip_writeback_if_not_writable (const ARM64SysRegField *field) +{ +/* +* KVM populates ID_DFR0_EL1.PerfMon even for AArch64-only guests but +* does not expose it as writable there, so skip it when it is not +* writable. +*/ +return field_matches (field,ID_DFR0_EL1_IDX ,"PerfMon" ); +} +/* -* Copy writable ID regs from isar.idregs[] to cpreg_list -* in case their value differs from the original init cpreg value +* Copy writable ID reg fields from isar.idregs[] into the KVM cpreg list, +* so the subsequent write_list_to_kvmstate() pushes them to KVM. +* Only writable fields are copied; fields that must not be written back +* (see arm_field_skip_writeback_*) are skipped. +* Returns -1 if any vCPU's ID reg value differs from the host value and the +* field is not writable. */ -static void kvm_arm_writable_idregs_to_cpreg_list (ARMCPU *cpu) +static int kvm_arm_write_idregs_to_cpreg_list (ARMCPU *cpu) {for (int i =0 ; i <NUM_ID_IDX ; i++) {ARM64SysReg *sysregdesc = &arm64_id_regs[i];ARMSysRegs sysreg = id_register_sysreg[i]; -uint64_t previous, new; +uint64_t writable_mask = sysregdesc->writable_mask; +uint64_t desired = cpu->isar.idregs[i]; +uint64_t previous, updated;uint64_t *cpreg;Quoted 15 lines
target/arm/kvm.c bool kvm_arm_cpu_post_load(ARMCPU *cpu) · line 1322
Quoted 13 lines
target/arm/kvm.c +10
-1-if (!sysregdesc->writable_mask) { + cpreg =kvm_arm_find_cpreg_ptr (cpu,idregs_sysreg_to_kvm_reg (sysreg)); +/* +* Registers such as DCZID_EL0 are not exposed through the cpreg +* list and are therefore not writable. Use the host value +* snapshotted at probe time as the reference to check the vCPU ID +* regs have the same value. +*/ + previous = cpreg ? *cpreg : arm_host_cpu_features.isar.idregs[i]; + +if (previous == desired) {continue ; }while at it you could also test all reserved fields here, RAZ, RES0/1 and make sure host value complies with the description.
Noted, will add it in v4
Warm Regards,
KhushitQuoted 81 lines
Quoted 76 lines
target/arm/kvm.c +43
-10- cpreg =kvm_arm_get_cpreg_ptr (cpu,idregs_sysreg_to_kvm_reg (sysreg)); - previous = *cpreg; - new = cpu->isar.idregs[i]; +for (int j =0 ; j < sysregdesc->fields_count; j++) { +const ARM64SysRegField *field = &sysregdesc->fields[j]; +uint64_t field_mask =arm_get_field_mask (field); +uint64_t prev_val = previous & field_mask; +uint64_t new_val = desired & field_mask; + +if (prev_val == new_val) { +continue ; + } + +if (arm_field_skip_writeback_always (field) || + (!arm_field_is_writable (field) && +arm_field_skip_writeback_if_not_writable (field))) { +/* Never write this field back; keep KVM's value. */ + writable_mask &= ~field_mask; +continue ; + } + +if (!arm_field_is_writable (field)) { +error_report ("%s.%s is not writable: host=0x%" PRIx64 +", requested=0x%" PRIx64, + sysregdesc->name, field->name, + prev_val >> field->shift, new_val >> field->shift); +return -1 ; + } + } + +if (!cpreg || !writable_mask) { +continue ; + } -if (previous != new) { - *cpreg = new; -trace_kvm_arm_writable_idregs_to_cpreg_list (sysregdesc->name, - previous, new); - } + updated = (previous & ~writable_mask) | (desired & writable_mask); +if (updated != previous) { + *cpreg = updated; +trace_kvm_arm_write_idregs_to_cpreg_list (sysregdesc->name, + previous, updated); + } } + +return 0 ; }void kvm_arm_reset_vcpu (ARMCPU *cpu)@@ -2235,8 +2318,11 @@ int kvm_arch_init_vcpu(CPUState *cs)if (ret) {return ret; } -/* overwrite writable ID regs with their updated property values */ -kvm_arm_writable_idregs_to_cpreg_list (cpu); +/* overwrite ID reg fields with their updated property values */ + ret =kvm_arm_write_idregs_to_cpreg_list (cpu); +if (ret) { +return ret; + } ret =write_list_to_kvmstate (cpu,KVM_PUT_FULL_STATE );if (!ret) {return -1 ;target/arm/trace-events +0
-0@@ -14,7 +14,7 @@ arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d" # kvm.c
kvm_arm_fixup_msi_route(uint64_t iova, uint64_t gpa)"MSI iova = 0x%"PRIx64" is translated into 0x%"PRIx64get_host_cpu_idregs(const char *name, uint64_t value)"scratch vcpu host value for %s is 0x%"PRIx64target/arm/trace-events +1
-1-kvm_arm_writable_idregs_to_cpreg_list(const char *name, uint64_t previous, uint64_t new) "%s overwrite default 0x%"PRIx64" with 0x%"PRIx64 +kvm_arm_write_idregs_to_cpreg_list(const char *name, uint64_t previous, uint64_t new) "%s overwrite default 0x%"PRIx64" with 0x%"PRIx64Quoted 2 lines
# cpu64.c get_sysreg_prop(const char *name, uint64_t value) "%s 0x%"PRIx64Thanks
Eric
Re: [RFC PATCH v3 08/19] target/arm/kvm: Handle writeback for special ID register fields
Quoted 42 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Hi Khushit,
Quoted 21 lines · Khushit Shah
Quoted 8 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 8 lines
Hi Khushit,
Quoted 3 lines · Khushit Shah
Some fields should not be written back to KVM for various reasons:
- ID_AA64PFR0_EL1.GIC / ID_PFR1_EL1.GIC are fabricated by KVM based on the gic-version property.so this is part of the overall handling of legacy composite options versus sysreg settings. To be the fact they both are consistent should be enforced upfront.
I have one idea on how to handle this:
- After we finalise cpu features, we recheck each command line prop passed. The final idregs[]’s prop value should be same as the user provided one from the cmdline.
For e.g., invalid configurations like:Quoted 8 lines
-cpu host,sve=on,SYSREG_ID_AA64PFR0_EL1_SVE=0 Or -cpu host,pauth=off,SYSREG_ID_AA64ISAR1_EL1_APA=2will be caught after finalise as both of those cannot be true at the same time.
If this makes sense, I can implement it for v4.
Quoted 8 lines
Yes consistency checking between low level props and legacy composite props is one of the next topic to be addressed on the prerequisite series. I think the next one is to improve the scratch vcpu dry run
inqmp_query_cpu_model_expansionwhich is not precise enough (it applies low level settings on a scratch vcpu whose init struct is based on some host assumptions rather than comprehensive property settings, this should be refined). If you want to work on this consistency checking problematic, feel free. Otherwise I will.
I will take a stab at consistency checking between SYSREG_ props and legacy properties in v4.
Warm Regards,
Khushit
Quoted 259 lines
Thanks
Eric
Quoted 255 lines
Quoted 8 lines
Quoted 8 lines
- KVM does not allow writing 0 to ID_DFR0_EL1.CopDbg, which breaks booting an AArch64-only guest on a host that also supports AArch32.
- ID_DFR0_EL1.PerfMon is populated by KVM even for AArch64-only guests but is not writable there.
-MPIDR_EL1is managed by KVM based on vCPU index.
- Hold off writing backCLIDR_EL1until we properly support exposing cache topology to a KVM guest.Quoted 6 lines
Sounds this deserves a prerequisite fix. I also have this hack in my series but this should be dealt with separately I think.
Quoted 3 lines
Some registers such as
DCZID_EL0are not exposed through the KVM cpreg list at all, but guest still sees the host value, we verify that vCPU's ID regs values match the host value.why isn't it cpreg then? Shouldn't we add it instead?
idk why KVM does not expose
DCZID_EL0.Quoted 39 lines
Quoted 39 lines
To do this, refactor
kvm_arm_writable_idregs_to_cpreg_listtokvm_arm_write_idregs_to_cpregs_list, which operates per field and now returns an error if a non-writable field mismatches with the host value.Signed-off-by Khushit Shah <[email protected]>---
target/arm/cpu-idregs.c | 19 +++++++ target/arm/cpu-idregs.h | 4 ++ target/arm/kvm.c | 116 ++++++++++++++++++++++++++++++++++------ target/arm/trace-events | 2 +- 4 files changed, 125 insertions(+), 16 deletions(-)target/arm/cpu-idregs.c +12
-0@@ -7,6 +7,7 @@* SPDX-License-Identifier: GPL-2.0-or-later */ #include "qemu/osdep.h" +#include "qemu/bitops.h" #include "qemu/error-report.h" #include "qapi/error.h" #include "cpu.h" @@ -94,3 +95,21 @@ ARM64SysReg arm64_id_regs[NUM_ID_IDX] = {#include "cpu-idregs.h.inc" }; +uint64_t arm_get_field_mask (const ARM64SysRegField *field) +{ +return MAKE_64BIT_MASK (field->shift, field->length); +} + +bool arm_field_is_writable (const ARM64SysRegField *field) +{ +uint64_t field_mask =arm_get_field_mask (field); + +return (arm64_id_regs[field->index].writable_mask & field_mask) + == field_mask;Quoted 8 lines
target/arm/cpu-idregs.c ARM64SysReg arm64_id_regs[NUM_ID_IDX] = { · line 114
Quoted 6 lines
target/arm/cpu-idregs.c +6
-0+} + +bool field_matches (const ARM64SysRegField *field,ARMIDRegisterIdx index, +const char *name) +{ +return field->index == index && !strcmp (field->name, name);why do you need to check both index and name. Only checking index should be sufficient.
Index gives register, name is field name.
Quoted 89 lines
Quoted 89 lines
target/arm/cpu-idregs.c +1
-0+}target/arm/cpu-idregs.h +4
-0@@ -38,4 +38,8 @@ typedef struct ARM64SysReg {*/ extern ARM64SysReg arm64_id_regs[NUM_ID_IDX ]; +uint64_t arm_get_field_mask (const ARM64SysRegField *field); +bool arm_field_is_writable (const ARM64SysRegField *field); +bool field_matches (const ARM64SysRegField *field,ARMIDRegisterIdx index, +const char *name);#endif target/arm/kvm.c +48
-4@@ -951,6 +951,16 @@ static uint64_t *kvm_arm_get_cpreg_ptr(ARMCPU *cpu, uint64_t regidx)return &cpu->cpreg_values[res - cpu->cpreg_indexes]; } +/* Like kvm_arm_get_cpreg_ptr, but returns NULL if the register is not found. */ +static uint64_t *kvm_arm_find_cpreg_ptr (ARMCPU *cpu,uint64_t regidx) +{ +uint64_t *res; + res =bsearch (®idx, cpu->cpreg_indexes, cpu->cpreg_array_len, +sizeof (uint64_t ), compare_u64); + +return res ? &cpu->cpreg_values[res - cpu->cpreg_indexes] :NULL ; +} +/** * kvm_arm_reg_syncs_via_cpreg_list: * @regidx: KVM register index @@ -1252,32 +1262,105 @@ bool kvm_arm_cpu_post_load(ARMCPU *cpu)return true; } +static bool arm_field_skip_writeback_always (const ARM64SysRegField *field) +{ +/* +* GIC is controlled by the gic-version property and fabricated by KVM +* when the vGIC device is created, so a named CPU model must not touch +* it. KVM also rejects writing 0 to ID_DFR0_EL1.CopDbg, which breaks +* booting a model that lacks AArch32 support on a host that supports +* it. MPIDR_EL1 is managed by KVM based on number of vCPUs, skip +* writing it back. Similarly, skip writing back CLIDR_EL1 till we +* properly support exposing cache for KVM guest. +*/ +return field_matches (field,ID_AA64PFR0_EL1_IDX ,"GIC" ) + ||field_matches (field,ID_PFR1_EL1_IDX ,"GIC" ) + ||field_matches (field,ID_DFR0_EL1_IDX ,"CopDbg" ) + || field->index ==MPIDR_EL1_IDX + || field->index ==CLIDR_EL1_IDX ; +} + +static bool arm_field_skip_writeback_if_not_writable (const ARM64SysRegField *field) +{ +/* +* KVM populates ID_DFR0_EL1.PerfMon even for AArch64-only guests but +* does not expose it as writable there, so skip it when it is not +* writable. +*/ +return field_matches (field,ID_DFR0_EL1_IDX ,"PerfMon" ); +} +/* -* Copy writable ID regs from isar.idregs[] to cpreg_list -* in case their value differs from the original init cpreg value +* Copy writable ID reg fields from isar.idregs[] into the KVM cpreg list, +* so the subsequent write_list_to_kvmstate() pushes them to KVM. +* Only writable fields are copied; fields that must not be written back +* (see arm_field_skip_writeback_*) are skipped. +* Returns -1 if any vCPU's ID reg value differs from the host value and the +* field is not writable. */ -static void kvm_arm_writable_idregs_to_cpreg_list (ARMCPU *cpu) +static int kvm_arm_write_idregs_to_cpreg_list (ARMCPU *cpu) {for (int i =0 ; i <NUM_ID_IDX ; i++) {ARM64SysReg *sysregdesc = &arm64_id_regs[i];ARMSysRegs sysreg = id_register_sysreg[i]; -uint64_t previous, new; +uint64_t writable_mask = sysregdesc->writable_mask; +uint64_t desired = cpu->isar.idregs[i]; +uint64_t previous, updated;uint64_t *cpreg;Quoted 15 lines
target/arm/kvm.c bool kvm_arm_cpu_post_load(ARMCPU *cpu) · line 1322
Quoted 13 lines
target/arm/kvm.c +10
-1-if (!sysregdesc->writable_mask) { + cpreg =kvm_arm_find_cpreg_ptr (cpu,idregs_sysreg_to_kvm_reg (sysreg)); +/* +* Registers such as DCZID_EL0 are not exposed through the cpreg +* list and are therefore not writable. Use the host value +* snapshotted at probe time as the reference to check the vCPU ID +* regs have the same value. +*/ + previous = cpreg ? *cpreg : arm_host_cpu_features.isar.idregs[i]; + +if (previous == desired) {continue ; }while at it you could also test all reserved fields here, RAZ, RES0/1 and make sure host value complies with the description.
Noted, will add it in v4
Warm Regards,
KhushitQuoted 81 lines
Quoted 76 lines
target/arm/kvm.c +43
-10- cpreg =kvm_arm_get_cpreg_ptr (cpu,idregs_sysreg_to_kvm_reg (sysreg)); - previous = *cpreg; - new = cpu->isar.idregs[i]; +for (int j =0 ; j < sysregdesc->fields_count; j++) { +const ARM64SysRegField *field = &sysregdesc->fields[j]; +uint64_t field_mask =arm_get_field_mask (field); +uint64_t prev_val = previous & field_mask; +uint64_t new_val = desired & field_mask; + +if (prev_val == new_val) { +continue ; + } + +if (arm_field_skip_writeback_always (field) || + (!arm_field_is_writable (field) && +arm_field_skip_writeback_if_not_writable (field))) { +/* Never write this field back; keep KVM's value. */ + writable_mask &= ~field_mask; +continue ; + } + +if (!arm_field_is_writable (field)) { +error_report ("%s.%s is not writable: host=0x%" PRIx64 +", requested=0x%" PRIx64, + sysregdesc->name, field->name, + prev_val >> field->shift, new_val >> field->shift); +return -1 ; + } + } + +if (!cpreg || !writable_mask) { +continue ; + } -if (previous != new) { - *cpreg = new; -trace_kvm_arm_writable_idregs_to_cpreg_list (sysregdesc->name, - previous, new); - } + updated = (previous & ~writable_mask) | (desired & writable_mask); +if (updated != previous) { + *cpreg = updated; +trace_kvm_arm_write_idregs_to_cpreg_list (sysregdesc->name, + previous, updated); + } } + +return 0 ; }void kvm_arm_reset_vcpu (ARMCPU *cpu)@@ -2235,8 +2318,11 @@ int kvm_arch_init_vcpu(CPUState *cs)if (ret) {return ret; } -/* overwrite writable ID regs with their updated property values */ -kvm_arm_writable_idregs_to_cpreg_list (cpu); +/* overwrite ID reg fields with their updated property values */ + ret =kvm_arm_write_idregs_to_cpreg_list (cpu); +if (ret) { +return ret; + } ret =write_list_to_kvmstate (cpu,KVM_PUT_FULL_STATE );if (!ret) {return -1 ;target/arm/trace-events +0
-0@@ -14,7 +14,7 @@ arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d" # kvm.c
kvm_arm_fixup_msi_route(uint64_t iova, uint64_t gpa)"MSI iova = 0x%"PRIx64" is translated into 0x%"PRIx64get_host_cpu_idregs(const char *name, uint64_t value)"scratch vcpu host value for %s is 0x%"PRIx64target/arm/trace-events +1
-1-kvm_arm_writable_idregs_to_cpreg_list(const char *name, uint64_t previous, uint64_t new) "%s overwrite default 0x%"PRIx64" with 0x%"PRIx64 +kvm_arm_write_idregs_to_cpreg_list(const char *name, uint64_t previous, uint64_t new) "%s overwrite default 0x%"PRIx64" with 0x%"PRIx64Quoted 2 lines
# cpu64.c get_sysreg_prop(const char *name, uint64_t value) "%s 0x%"PRIx64Thanks
Eric
RFC PATCH v3 9/19 target/arm: Add named cpu model infra + graviton3 named model
In reply to Khushit ShahFrom: Shaju Abraham <[email protected]>
Introduce a small named-CPU-model layer on top of the field-backed property infrastructure. Each model is a flat table of (name, value) overrides and a parent pointer. At instance-init, the parent chain is walked root-first and every level's properties are applied via QOM, so a child entry overrides its ancestors for the same name.
For example, the graviton3-v1 named model hierarchy is:
non-zero-defaults-v1 Known non-zero default ID regs field values
arm-v8_4-a-v1 ARMv8.4-A architectural mandate
neoverse-v1-v1 Neoverse V1
graviton3-v1 AWS Graviton3non-zero-defaults-v1:
Field that should be populated with some non zero value by default.
arm-v8_4-a-v1:
Only features mandated by the ARM ARM.
neoverse-v1-v1:
Reference manual derived feature values for the reference core. Values differ from TRM values based on what was exposed to the guest with -cpu host.
graviton3-v1:
SoC integration choices (crypto pin, cache hints, PAuth alg).
The model values are figured out from ID register dump visible to QEMU with -cpu host on Graviton3 machine.
Model realization:
1. Zero out ID regs array.
2. Add all properties to the CPU Object
3. arm_realize_model_chain: Walk the parent chain from root first and apply all the properties.
--- hw/arm/virt.c | 5 + target/arm/arm-cpu-models.c | 336 ++++++++++++++++++++++++++++++++++++ target/arm/arm-cpu-models.h | 35 ++++ target/arm/meson.build | 7 +- 4 files changed, 381 insertions(+), 2 deletions(-) create mode 100644 target/arm/arm-cpu-models.c create mode 100644 target/arm/arm-cpu-models.h
hw/arm/virt.c +5 -0
@@ -3812,6 +3812,11 @@ static GPtrArray *virt_get_valid_cpu_types(const MachineState *ms)g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("host" ))); } } +if (kvm_enabled () &&target_aarch64 ()) { +g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("arm-v8_4-a-v1" ))); +g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("neoverse-v1-v1" ))); +g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("graviton3-v1" ))); + }g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("max" )));return vct;
target/arm/arm-cpu-models.c new file +336 -0
336 lines not on this page · raw message
target/arm/arm-cpu-models.h new file +35 -0
@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* ARM named CPU model definitions - public API. +*/ +#ifndef ARM_CPU_MODELS_H +#define ARM_CPU_MODELS_H + +#include "qapi/error.h" +#include "qom/object.h" + +typedef enum ArmModelPropType { +ARM_MODEL_PROP_BOOL , +ARM_MODEL_PROP_NUM , +}ArmModelPropType ; + +typedef struct ArmModelPropValue { +const char *name; +ArmModelPropType type; +union { +bool b; +uint64_t num; + } u; +}ArmModelPropValue ; + +typedef struct ArmNamedCpuModel { +const char *name; +const char *parent; +const ArmModelPropValue *props; +}ArmNamedCpuModel ; + +void arm_register_named_cpu_models (void ); + +const ArmNamedCpuModel *arm_find_model (const char *name); + +#endif /* ARM_CPU_MODELS_H */
target/arm/meson.build +5 -2
@@ -10,7 +10,7 @@ arm_user_ss.add(files('gdbstub.c')) arm_ss.add(when: 'TARGET_AARCH64', if_true: files( 'cpu64.c', - 'gdbstub64.c' + 'gdbstub64.c', )) arm_common_ss.add(files(
@@ -21,7 +21,10 @@ arm_common_system_ss.add(files( 'arm-qmp-cmds.c', 'cpu-idregs.c', )) -arm_system_ss.add(when: 'CONFIG_KVM', if_true: files('hyp_gdbstub.c', 'kvm.c')) +arm_system_ss.add(when: 'TARGET_AARCH64', if_true: files('arm-cpu-models.c')) +arm_system_ss.add(when: 'CONFIG_KVM', + if_true: files('hyp_gdbstub.c', + 'kvm.c')) arm_system_ss.add(when: 'CONFIG_HVF', if_true: files('hyp_gdbstub.c')) arm_user_ss.add(files('cpu.c'))
Signature · 1 line
2.52.0
Re: [RFC PATCH v3 09/19] target/arm: Add named cpu model infra + graviton3 named model
Hi Khushit,
Quoted 92 lines · Khushit Shah
From: Shaju Abraham <[email protected]>
Introduce a small named-CPU-model layer on top of the field-backed property infrastructure. Each model is a flat table of (name, value) overrides and a parent pointer. At instance-init, the parent chain is walked root-first and every level's properties are applied via QOM, so a child entry overrides its ancestors for the same name.
For example, the graviton3-v1 named model hierarchy is:
non-zero-defaults-v1 Known non-zero default ID regs field valuesarm-v8_4-a-v1 ARMv8.4-A architectural mandate neoverse-v1-v1 Neoverse V1 graviton3-v1 AWS Graviton3non-zero-defaults-v1:
Field that should be populated with some non zero value by default.arm-v8_4-a-v1:
Only features mandated by the ARM ARM.neoverse-v1-v1:
Reference manual derived feature values for the reference core. Values differ from TRM values based on what was exposed to the guest with -cpu host.graviton3-v1:
SoC integration choices (crypto pin, cache hints, PAuth alg).The model values are figured out from ID register dump visible to QEMU with -cpu host on Graviton3 machine.
Model realization:
1. Zero out ID regs array.
2. Add all properties to the CPU Object
3.arm_realize_model_chain: Walk the parent chain from root first and apply all the properties.Co-authored-by Shaju Abraham <[email protected]>Signed-off-by Khushit Shah <[email protected]>--- hw/arm/virt.c | 5 + target/arm/arm-cpu-models.c | 336 ++++++++++++++++++++++++++++++++++++ target/arm/arm-cpu-models.h | 35 ++++ target/arm/meson.build | 7 +- 4 files changed, 381 insertions(+), 2 deletions(-) create mode 100644 target/arm/arm-cpu-models.c create mode 100644 target/arm/arm-cpu-models.hhw/arm/virt.c +5
-0@@ -3812,6 +3812,11 @@ static GPtrArray *virt_get_valid_cpu_types(const MachineState *ms)g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("host" ))); } } +if (kvm_enabled () &&target_aarch64 ()) { +g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("arm-v8_4-a-v1" ))); +g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("neoverse-v1-v1" ))); +g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("graviton3-v1" ))); + } g_ptr_array_add(vct, g_strdup(ARM_CPU_TYPE_NAME("max"))); return vct; diff --git a/target/arm/arm-cpu-models.c
b/target/arm/arm-cpu-models.cnew file mode 100644 index 0000000000..747e0df010 ---/dev/null+++b/target/arm/arm-cpu-models.chw/arm/virt.c +0
-0@@ -0,0 +1,336 @@ +/* + * ARM named CPU model definitions. + * + *Each model is defined as an array of
MODEL_PROPmacro, listing only +
* the properties that DIFFER from the parent model. + * + * At realisation the parent chain is walked root-first and + * every level's props are applied via QOM, so the leaf's values + * naturally override its ancestors. + * + * Hierarchy: + * + * non-zero-defaults-v1 Known non-zero default ID reg field values + * arm-v8_4-a-v1 ARMv8.4-A architectural mandate + * neoverse-v1-v1 Neoverse V1 (TRM 102649) + * graviton3-v1 AWS Graviton3 + * + *
SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h"hw/arm/virt.c +18
-0+#include "qapi/error.h" +#include "qemu/error-report.h" +#include "system/kvm.h" +#include "cpu.h" +#include "internals.h" +#include "kvm_arm.h" +#include "arm-cpu-models.h" +#include "cpu-idregs.h" + +#define MODEL_PROP_FIELD_STR str +#define MODEL_PROP_FIELD_BOOL b +#define MODEL_PROP_FIELD_NUM num + +#define MODEL_PROP (_name, _type, _value) \ + { .name = (_name), .type = ARM_MODEL_PROP_##_type, \ + .u.MODEL_PROP_FIELD_##_type = (_value) } + +#define MODEL_PROP_END { .name = NULL }
hw/arm/virt.c
Quoted 10 lines
hw/arm/virt.c +10
-0+ +/* +* These fields should be populated with some non-zero default values. +*/ +static const ArmModelPropValue non_zero_defaults_v1_props[] = { +/* ID_AA64PFR0_EL1 */ +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_EL0" ,NUM ,0b0001 ), +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_EL1" ,NUM ,0b0001 ), +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_FP" ,NUM ,0b1111 ), +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_AdvSIMD" ,NUM ,0b1111 ),
somehow we end up with something that is quite similar to TCG CPU definitions like inaarch64_neoverse_n1_initfn(). To me this is in general more readable because we use name fields instead of putting the full reg value. This does not prevent us from adding comments along settings to make this more readable and explicit.
hw/arm/virt.c
Quoted 3 lines
hw/arm/virt.c +3
-0+ +/* ID_AA64PFR1_EL1 */ + MODEL_PROP("SYSREG_ID_AA64PFR1_EL1_MTE_frac", NUM, 0b1111),
so I still believe we want a wrapper that transparently either sets a prop if the field happens to be writable or simply performs checks against the host if the prop is not available.
Quoted 11 lines
hw/arm/virt.c +11
-0+ +/* ID_AA64MMFR0_EL1 */ +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran64" ,NUM ,0b1111 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran4" ,NUM ,0b1111 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran16_2" ,NUM ,0b0001 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran64_2" ,NUM ,0b0001 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran4_2" ,NUM ,0b0001 ), + +/* ID_AA64DFR0_EL1 */ +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_DebugVer" ,NUM ,0x6 ), + MODEL_PROP("SYSREG_ID_AA64DFR0_EL1_DoubleLock", NUM, 0b1111),
hw/arm/virt.c
Quoted 10 lines
hw/arm/virt.c +10
-0+ +/* CTR_EL0 */ +MODEL_PROP ("SYSREG_CTR_EL0_L1Ip" ,NUM ,0b10 ), +MODEL_PROP ("SYSREG_CTR_EL0_RES1_31" ,NUM ,1 ), + +/* ID_AA64MMFR4_EL1 */ +MODEL_PROP ("SYSREG_ID_AA64MMFR4_EL1_E2H0" ,NUM ,0b1111 ), + + MODEL_PROP_END, +};
To ease the review I would suggest to put a dump of all id regs of a leaf modelin the commit description. It is less error prone that understanding the various overrides.
I would suggest to have separate patches for each model too.
Quoted 319 lines
hw/arm/virt.c +263
-0+ +static const ArmModelPropValue armv8_4_a_v1_props[] = { +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_CRC32" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_Atomic" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_HPDS" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_LO" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_DPB" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_RAS" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_RAS_frac" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_PAN" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_UAO" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_CnP" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_IESB" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_DIT" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_DebugVer" ,NUM ,9 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_PMUVer" ,NUM ,5 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_TS" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_LRCPC" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_AT" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_IDS" ,NUM ,1 ), +/* KVM zeroes out these field when MTE is not enabled. */ +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_MTE_frac" ,NUM ,0 ), +MODEL_PROP_END , +}; + +static const ArmModelPropValue neoverse_v1_v1_props[] = { +MODEL_PROP ("SYSREG_MIDR_EL1_Implementer" ,NUM ,0x41 ), +MODEL_PROP ("SYSREG_MIDR_EL1_Variant" ,NUM ,0x1 ), +MODEL_PROP ("SYSREG_MIDR_EL1_Architecture" ,NUM ,0xF ), +MODEL_PROP ("SYSREG_MIDR_EL1_PartNum" ,NUM ,0xD40 ), +MODEL_PROP ("SYSREG_MIDR_EL1_Revision" ,NUM ,0x1 ), + +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_BRPs" ,NUM ,0x5 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_WRPs" ,NUM ,0x3 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_CTX_CMPs" ,NUM ,0x1 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_DoubleLock" ,NUM ,0xF ), + +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_RDM" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_DP" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_FHM" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_DPB" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_JSCVT" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_FCMA" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_BF16" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_DGH" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_I8MM" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_FP" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_AdvSIMD" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_RAS" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_RAS_frac" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_CSV2" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_CSV2_frac" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_CSV3" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_SSBS" ,NUM ,2 ), + +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_PARange" ,NUM ,5 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_ASIDBits" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_BigEnd" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_SNSMem" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran4" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran16" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran64" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran4_2" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran16_2" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran64_2" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_HAFDBS" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_VMIDBits" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_VH" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_HPDS" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_XNX" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_SpecSEI" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_FWB" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_BBM" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_EVT" ,NUM ,2 ), + +MODEL_PROP ("SYSREG_ID_AA64MMFR4_EL1_E2H0" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_CTR_EL0_IminLine" ,NUM ,4 ), +MODEL_PROP ("SYSREG_CTR_EL0_L1Ip" ,NUM ,3 ), +MODEL_PROP ("SYSREG_CTR_EL0_DminLine" ,NUM ,4 ), +MODEL_PROP ("SYSREG_CTR_EL0_ERG" ,NUM ,4 ), +MODEL_PROP ("SYSREG_CTR_EL0_CWG" ,NUM ,4 ), + +MODEL_PROP ("SYSREG_DCZID_EL0_BS" ,NUM ,0x4 ), + +/* pauth */ +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_APA" ,NUM ,3 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_GPA" ,NUM ,1 ), + +/* sve */ +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_SVE" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ZFR0_EL1_BF16" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ZFR0_EL1_I8MM" ,NUM ,1 ), +MODEL_PROP ("sve128" ,BOOL , true), + +MODEL_PROP_END , +}; + +static const ArmModelPropValue graviton3_v1_props[] = { +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_AES" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SHA1" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SHA2" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SHA3" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SM3" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SM4" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_RNDR" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_CTR_EL0_IDC" ,NUM ,1 ), +MODEL_PROP ("SYSREG_CTR_EL0_DIC" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_REVIDR_EL1_VAL" ,NUM ,1 ), + +MODEL_PROP_END , +}; + +static const ArmNamedCpuModel arm_cpu_models[] = { + { + .name ="non-zero-defaults-v1" , + .parent =NULL , + .props = non_zero_defaults_v1_props, + }, + { + .name ="arm-v8_4-a-v1" , + .parent ="non-zero-defaults-v1" , + .props = armv8_4_a_v1_props, + }, + { + .name ="neoverse-v1-v1" , + .parent ="arm-v8_4-a-v1" , + .props = neoverse_v1_v1_props, + }, + { + .name ="graviton3-v1" , + .parent ="neoverse-v1-v1" , + .props = graviton3_v1_props, + }, +}; + +static ARMCPUInfo arm_named_cpu_infos[ARRAY_SIZE (arm_cpu_models)]; +const ArmNamedCpuModel *arm_find_model (const char *name) +{ +size_t i; +for (i =0 ; i <ARRAY_SIZE (arm_cpu_models); i++) { +if (g_str_equal (arm_cpu_models[i].name, name)) { +return &arm_cpu_models[i]; + } + } +return NULL ; +} + +static void arm_apply_model_props (Object *obj,const ArmModelPropValue *props, +Error **errp) +{ +const ArmModelPropValue *pv; +ERRP_GUARD (); + +for (pv = props; pv->name; pv++) { +switch (pv->type) { +case ARM_MODEL_PROP_BOOL : +object_property_set_bool (obj, pv->name, pv->u.b, errp); +break ; +case ARM_MODEL_PROP_NUM : +object_property_set_uint (obj, pv->name, pv->u.num, errp); +break ; +default : +g_assert_not_reached (); + } +if (*errp) { +error_prepend (errp,"property '%s': " , pv->name); +return ; + } + } +} + +static void arm_realize_model_chain (Object *obj,const ArmNamedCpuModel *model, +Error **errp) +{ +const ArmNamedCpuModel *cur, *parent; +const ArmNamedCpuModel *chain[ARRAY_SIZE (arm_cpu_models)]; +size_t depth =0 ; +for (cur = model; cur; ) { +if (depth >=ARRAY_SIZE (chain)) { +error_setg (errp,"model '%s': parent chain too deep " +"(possible cycle)" , model->name); +return ; + } + chain[depth++] = cur; + +if (!cur->parent) { +break ; + } + parent =arm_find_model (cur->parent); +if (!parent) { +error_setg (errp,"model '%s': unknown parent '%s'" , + cur->name, cur->parent); +return ; + } + cur = parent; + } + +while (depth--) { +arm_apply_model_props (obj, chain[depth]->props, errp); +if (*errp) { +return ; + } + } +} + +static void arm_named_cpu_initfn (Object *obj) +{ +ARMCPU *cpu =ARM_CPU (obj); +ARMCPUClass *acc =ARM_CPU_GET_CLASS (obj); +const ArmNamedCpuModel *model =arm_find_model (acc->info->name); +if (!model) { +error_report ("'%s' CPU model entry not found)" , + acc->info->name); +return ; + } + +if (!kvm_enabled ()) { +error_report ("'%s' CPU model requires KVM (-accel kvm)" , + acc->info->name); +return ; + } + +kvm_arm_set_cpu_features_from_host (cpu); +if (!arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) { +return ; + } + +/* 1. Reset ID regs to 0 */ +memset (cpu->isar.idregs,0 ,sizeof (cpu->isar.idregs)); + +/* 2. Add sveNNNN and SYSREG_ properties */ +aarch64_add_sve_properties (obj); +aarch64_add_idregs_properties (obj); + +/* 3. Realize the model chain. */ +arm_realize_model_chain (obj, model, &error_abort); +} + +void arm_register_named_cpu_models (void ) +{ +size_t i; +for (i =0 ; i <ARRAY_SIZE (arm_cpu_models); i++) { + arm_named_cpu_infos[i].name = arm_cpu_models[i].name; + arm_named_cpu_infos[i].initfn = arm_named_cpu_initfn; +arm_cpu_register (&arm_named_cpu_infos[i]); + } +} + +type_init (arm_register_named_cpu_models)target/arm/arm-cpu-models.h new file +35
-0@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* ARM named CPU model definitions - public API. +*/ +#ifndef ARM_CPU_MODELS_H +#define ARM_CPU_MODELS_H + +#include "qapi/error.h" +#include "qom/object.h" + +typedef enum ArmModelPropType { +ARM_MODEL_PROP_BOOL , +ARM_MODEL_PROP_NUM , +}ArmModelPropType ; + +typedef struct ArmModelPropValue { +const char *name; +ArmModelPropType type; +union { +bool b; +uint64_t num; + } u; +}ArmModelPropValue ; + +typedef struct ArmNamedCpuModel { +const char *name; +const char *parent; +const ArmModelPropValue *props; +}ArmNamedCpuModel ; + +void arm_register_named_cpu_models (void ); + +const ArmNamedCpuModel *arm_find_model (const char *name); + +#endif /* ARM_CPU_MODELS_H */ target/arm/meson.build +1
-1@@ -10,7 +10,7 @@ arm_user_ss.add(files('gdbstub.c')) arm_ss.add(when: 'TARGET_AARCH64', if_true: files( 'cpu64.c', - 'gdbstub64.c' + 'gdbstub64.c', )) arm_common_ss.add(files(@@ -21,7 +21,10 @@ arm_common_system_ss.add(files( 'arm-qmp-cmds.c',
target/arm/meson.build arm_common_system_ss.add(files( · line 30
Quoted 10 lines
target/arm/meson.build +4
-1'cpu-idregs.c', )) -arm_system_ss.add(when: 'CONFIG_KVM', if_true: files('hyp_gdbstub.c', 'kvm.c')) +arm_system_ss.add(when: 'TARGET_AARCH64', if_true: files('arm-cpu-models.c')) +arm_system_ss.add(when: 'CONFIG_KVM', + if_true: files('hyp_gdbstub.c', + 'kvm.c')) arm_system_ss.add(when: 'CONFIG_HVF', if_true: files('hyp_gdbstub.c')) arm_user_ss.add(files('cpu.c'))
Thanks
Eric
Re: [RFC PATCH v3 09/19] target/arm: Add named cpu model infra + graviton3 named model
In reply to Khushit ShahHi Khushit,
Quoted 8 lines · Khushit Shah
From: Shaju Abraham <[email protected]>
Introduce a small named-CPU-model layer on top of the field-backed property infrastructure. Each model is a flat table of (name, value) overrides and a parent pointer. At instance-init, the parent chain is walked root-first and every level's properties are applied via QOM, so a child entry overrides its ancestors for the same name.
Quoted 8 lines
For example, the graviton3-v1 named model hierarchy is:
non-zero-defaults-v1 Known non-zero default ID regs field valuesarm-v8_4-a-v1 ARMv8.4-A architectural mandate neoverse-v1-v1 Neoverse V1 graviton3-v1 AWS Graviton3non-zero-defaults-v1:
Field that should be populated with some non zero value by default.
following which specification? This is not clear to me. Is that layer really meaningful? Shouldn't we start with the next one?
Quoted 66 lines
arm-v8_4-a-v1:
Only features mandated by the ARM ARM.neoverse-v1-v1:
Reference manual derived feature values for the reference core. Values differ from TRM values based on what was exposed to the guest with -cpu host.graviton3-v1:
SoC integration choices (crypto pin, cache hints, PAuth alg).The model values are figured out from ID register dump visible to QEMU with -cpu host on Graviton3 machine.
Model realization:
1. Zero out ID regs array.
2. Add all properties to the CPU Object
3.arm_realize_model_chain: Walk the parent chain from root first and apply all the properties.Co-authored-by Shaju Abraham <[email protected]>Signed-off-by Khushit Shah <[email protected]>--- hw/arm/virt.c | 5 + target/arm/arm-cpu-models.c | 336 ++++++++++++++++++++++++++++++++++++ target/arm/arm-cpu-models.h | 35 ++++ target/arm/meson.build | 7 +- 4 files changed, 381 insertions(+), 2 deletions(-) create mode 100644 target/arm/arm-cpu-models.c create mode 100644 target/arm/arm-cpu-models.hhw/arm/virt.c +5
-0@@ -3812,6 +3812,11 @@ static GPtrArray *virt_get_valid_cpu_types(const MachineState *ms)g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("host" ))); } } +if (kvm_enabled () &&target_aarch64 ()) { +g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("arm-v8_4-a-v1" ))); +g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("neoverse-v1-v1" ))); +g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("graviton3-v1" ))); + } g_ptr_array_add(vct, g_strdup(ARM_CPU_TYPE_NAME("max"))); return vct; diff --git a/target/arm/arm-cpu-models.c
b/target/arm/arm-cpu-models.cnew file mode 100644 index 0000000000..747e0df010 ---/dev/null+++b/target/arm/arm-cpu-models.chw/arm/virt.c +0
-0@@ -0,0 +1,336 @@ +/* + * ARM named CPU model definitions. + * + *Each model is defined as an array of
MODEL_PROPmacro, listing only +
* the properties that DIFFER from the parent model. + * + * At realisation the parent chain is walked root-first and + * every level's props are applied via QOM, so the leaf's values + * naturally override its ancestors. + * + * Hierarchy: + * + * non-zero-defaults-v1 Known non-zero default ID reg field values + * arm-v8_4-a-v1 ARMv8.4-A architectural mandate + * neoverse-v1-v1 Neoverse V1 (TRM 102649) + * graviton3-v1 AWS Graviton3 + * + *
SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h"hw/arm/virt.c +8
-0+#include "qapi/error.h" +#include "qemu/error-report.h" +#include "system/kvm.h" +#include "cpu.h" +#include "internals.h" +#include "kvm_arm.h" +#include "arm-cpu-models.h" +#include "cpu-idregs.h"
hw/arm/virt.c
Quoted 10 lines
hw/arm/virt.c +10
-0+ +#define MODEL_PROP_FIELD_STR str +#define MODEL_PROP_FIELD_BOOL b +#define MODEL_PROP_FIELD_NUM num + +#define MODEL_PROP (_name, _type, _value) \ + { .name = (_name), .type = ARM_MODEL_PROP_##_type, \ + .u.MODEL_PROP_FIELD_##_type = (_value) } + +#define MODEL_PROP_END { .name = NULL }
Regarding settings somehow we end up with something that is quite similar to TCG CPU
definitions like inaarch64_neoverse_n1_initfn(). To me this is in general more readable because we use name fields instead of putting the full reg value. This does not prevent us from adding comments along settings to make this more readable and explicit.
hw/arm/virt.c
Quoted 13 lines
hw/arm/virt.c +13
-0+ +/* +* These fields should be populated with some non-zero default values. +*/ +static const ArmModelPropValue non_zero_defaults_v1_props[] = { +/* ID_AA64PFR0_EL1 */ +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_EL0" ,NUM ,0b0001 ), +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_EL1" ,NUM ,0b0001 ), +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_FP" ,NUM ,0b1111 ), +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_AdvSIMD" ,NUM ,0b1111 ), + +/* ID_AA64PFR1_EL1 */ +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_MTE_frac" ,NUM ,0b1111 ),
so I still believe we want a wrapper that transparently either sets a prop if the field happens to be writable or simply performs checks against the host if the prop is not available.
Quoted 11 lines
hw/arm/virt.c +11
-0+ +/* ID_AA64MMFR0_EL1 */ +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran64" ,NUM ,0b1111 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran4" ,NUM ,0b1111 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran16_2" ,NUM ,0b0001 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran64_2" ,NUM ,0b0001 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran4_2" ,NUM ,0b0001 ), + +/* ID_AA64DFR0_EL1 */ +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_DebugVer" ,NUM ,0x6 ), + MODEL_PROP("SYSREG_ID_AA64DFR0_EL1_DoubleLock", NUM, 0b1111),
hw/arm/virt.c
Quoted 10 lines
hw/arm/virt.c +10
-0+ +/* CTR_EL0 */ +MODEL_PROP ("SYSREG_CTR_EL0_L1Ip" ,NUM ,0b10 ), +MODEL_PROP ("SYSREG_CTR_EL0_RES1_31" ,NUM ,1 ), + +/* ID_AA64MMFR4_EL1 */ +MODEL_PROP ("SYSREG_ID_AA64MMFR4_EL1_E2H0" ,NUM ,0b1111 ), + + MODEL_PROP_END, +};
To ease the review I would suggest to put a dump of all id regs of a leaf model in the commit description. It is less error prone that understanding the various overrides.
I would suggest to have separate patches for each model too.
So you said a leaf model shall have explicit values for each field, including non writable ones. The code does not check that. How do we make sure we are not missing settings?
Quoted 319 lines
hw/arm/virt.c +263
-0+ +static const ArmModelPropValue armv8_4_a_v1_props[] = { +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_CRC32" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_Atomic" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_HPDS" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_LO" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_DPB" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_RAS" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_RAS_frac" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_PAN" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_UAO" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_CnP" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_IESB" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_DIT" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_DebugVer" ,NUM ,9 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_PMUVer" ,NUM ,5 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_TS" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_LRCPC" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_AT" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_IDS" ,NUM ,1 ), +/* KVM zeroes out these field when MTE is not enabled. */ +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_MTE_frac" ,NUM ,0 ), +MODEL_PROP_END , +}; + +static const ArmModelPropValue neoverse_v1_v1_props[] = { +MODEL_PROP ("SYSREG_MIDR_EL1_Implementer" ,NUM ,0x41 ), +MODEL_PROP ("SYSREG_MIDR_EL1_Variant" ,NUM ,0x1 ), +MODEL_PROP ("SYSREG_MIDR_EL1_Architecture" ,NUM ,0xF ), +MODEL_PROP ("SYSREG_MIDR_EL1_PartNum" ,NUM ,0xD40 ), +MODEL_PROP ("SYSREG_MIDR_EL1_Revision" ,NUM ,0x1 ), + +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_BRPs" ,NUM ,0x5 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_WRPs" ,NUM ,0x3 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_CTX_CMPs" ,NUM ,0x1 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_DoubleLock" ,NUM ,0xF ), + +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_RDM" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_DP" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_FHM" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_DPB" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_JSCVT" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_FCMA" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_BF16" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_DGH" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_I8MM" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_FP" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_AdvSIMD" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_RAS" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_RAS_frac" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_CSV2" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_CSV2_frac" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_CSV3" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_SSBS" ,NUM ,2 ), + +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_PARange" ,NUM ,5 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_ASIDBits" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_BigEnd" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_SNSMem" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran4" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran16" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran64" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran4_2" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran16_2" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran64_2" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_HAFDBS" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_VMIDBits" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_VH" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_HPDS" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_XNX" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_SpecSEI" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_FWB" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_BBM" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_EVT" ,NUM ,2 ), + +MODEL_PROP ("SYSREG_ID_AA64MMFR4_EL1_E2H0" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_CTR_EL0_IminLine" ,NUM ,4 ), +MODEL_PROP ("SYSREG_CTR_EL0_L1Ip" ,NUM ,3 ), +MODEL_PROP ("SYSREG_CTR_EL0_DminLine" ,NUM ,4 ), +MODEL_PROP ("SYSREG_CTR_EL0_ERG" ,NUM ,4 ), +MODEL_PROP ("SYSREG_CTR_EL0_CWG" ,NUM ,4 ), + +MODEL_PROP ("SYSREG_DCZID_EL0_BS" ,NUM ,0x4 ), + +/* pauth */ +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_APA" ,NUM ,3 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_GPA" ,NUM ,1 ), + +/* sve */ +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_SVE" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ZFR0_EL1_BF16" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ZFR0_EL1_I8MM" ,NUM ,1 ), +MODEL_PROP ("sve128" ,BOOL , true), + +MODEL_PROP_END , +}; + +static const ArmModelPropValue graviton3_v1_props[] = { +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_AES" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SHA1" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SHA2" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SHA3" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SM3" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SM4" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_RNDR" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_CTR_EL0_IDC" ,NUM ,1 ), +MODEL_PROP ("SYSREG_CTR_EL0_DIC" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_REVIDR_EL1_VAL" ,NUM ,1 ), + +MODEL_PROP_END , +}; + +static const ArmNamedCpuModel arm_cpu_models[] = { + { + .name ="non-zero-defaults-v1" , + .parent =NULL , + .props = non_zero_defaults_v1_props, + }, + { + .name ="arm-v8_4-a-v1" , + .parent ="non-zero-defaults-v1" , + .props = armv8_4_a_v1_props, + }, + { + .name ="neoverse-v1-v1" , + .parent ="arm-v8_4-a-v1" , + .props = neoverse_v1_v1_props, + }, + { + .name ="graviton3-v1" , + .parent ="neoverse-v1-v1" , + .props = graviton3_v1_props, + }, +}; + +static ARMCPUInfo arm_named_cpu_infos[ARRAY_SIZE (arm_cpu_models)]; +const ArmNamedCpuModel *arm_find_model (const char *name) +{ +size_t i; +for (i =0 ; i <ARRAY_SIZE (arm_cpu_models); i++) { +if (g_str_equal (arm_cpu_models[i].name, name)) { +return &arm_cpu_models[i]; + } + } +return NULL ; +} + +static void arm_apply_model_props (Object *obj,const ArmModelPropValue *props, +Error **errp) +{ +const ArmModelPropValue *pv; +ERRP_GUARD (); + +for (pv = props; pv->name; pv++) { +switch (pv->type) { +case ARM_MODEL_PROP_BOOL : +object_property_set_bool (obj, pv->name, pv->u.b, errp); +break ; +case ARM_MODEL_PROP_NUM : +object_property_set_uint (obj, pv->name, pv->u.num, errp); +break ; +default : +g_assert_not_reached (); + } +if (*errp) { +error_prepend (errp,"property '%s': " , pv->name); +return ; + } + } +} + +static void arm_realize_model_chain (Object *obj,const ArmNamedCpuModel *model, +Error **errp) +{ +const ArmNamedCpuModel *cur, *parent; +const ArmNamedCpuModel *chain[ARRAY_SIZE (arm_cpu_models)]; +size_t depth =0 ; +for (cur = model; cur; ) { +if (depth >=ARRAY_SIZE (chain)) { +error_setg (errp,"model '%s': parent chain too deep " +"(possible cycle)" , model->name); +return ; + } + chain[depth++] = cur; + +if (!cur->parent) { +break ; + } + parent =arm_find_model (cur->parent); +if (!parent) { +error_setg (errp,"model '%s': unknown parent '%s'" , + cur->name, cur->parent); +return ; + } + cur = parent; + } + +while (depth--) { +arm_apply_model_props (obj, chain[depth]->props, errp); +if (*errp) { +return ; + } + } +} + +static void arm_named_cpu_initfn (Object *obj) +{ +ARMCPU *cpu =ARM_CPU (obj); +ARMCPUClass *acc =ARM_CPU_GET_CLASS (obj); +const ArmNamedCpuModel *model =arm_find_model (acc->info->name); +if (!model) { +error_report ("'%s' CPU model entry not found)" , + acc->info->name); +return ; + } + +if (!kvm_enabled ()) { +error_report ("'%s' CPU model requires KVM (-accel kvm)" , + acc->info->name); +return ; + } + +kvm_arm_set_cpu_features_from_host (cpu); +if (!arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) { +return ; + } + +/* 1. Reset ID regs to 0 */ +memset (cpu->isar.idregs,0 ,sizeof (cpu->isar.idregs)); + +/* 2. Add sveNNNN and SYSREG_ properties */ +aarch64_add_sve_properties (obj); +aarch64_add_idregs_properties (obj); + +/* 3. Realize the model chain. */ +arm_realize_model_chain (obj, model, &error_abort); +} + +void arm_register_named_cpu_models (void ) +{ +size_t i; +for (i =0 ; i <ARRAY_SIZE (arm_cpu_models); i++) { + arm_named_cpu_infos[i].name = arm_cpu_models[i].name; + arm_named_cpu_infos[i].initfn = arm_named_cpu_initfn; +arm_cpu_register (&arm_named_cpu_infos[i]); + } +} + +type_init (arm_register_named_cpu_models)target/arm/arm-cpu-models.h new file +35
-0@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* ARM named CPU model definitions - public API. +*/ +#ifndef ARM_CPU_MODELS_H +#define ARM_CPU_MODELS_H + +#include "qapi/error.h" +#include "qom/object.h" + +typedef enum ArmModelPropType { +ARM_MODEL_PROP_BOOL , +ARM_MODEL_PROP_NUM , +}ArmModelPropType ; + +typedef struct ArmModelPropValue { +const char *name; +ArmModelPropType type; +union { +bool b; +uint64_t num; + } u; +}ArmModelPropValue ; + +typedef struct ArmNamedCpuModel { +const char *name; +const char *parent; +const ArmModelPropValue *props; +}ArmNamedCpuModel ; + +void arm_register_named_cpu_models (void ); + +const ArmNamedCpuModel *arm_find_model (const char *name); + +#endif /* ARM_CPU_MODELS_H */ target/arm/meson.build +1
-1@@ -10,7 +10,7 @@ arm_user_ss.add(files('gdbstub.c')) arm_ss.add(when: 'TARGET_AARCH64', if_true: files( 'cpu64.c', - 'gdbstub64.c' + 'gdbstub64.c', )) arm_common_ss.add(files(@@ -21,7 +21,10 @@ arm_common_system_ss.add(files( 'arm-qmp-cmds.c',
target/arm/meson.build arm_common_system_ss.add(files( · line 30
Quoted 10 lines
target/arm/meson.build +4
-1'cpu-idregs.c', )) -arm_system_ss.add(when: 'CONFIG_KVM', if_true: files('hyp_gdbstub.c', 'kvm.c')) +arm_system_ss.add(when: 'TARGET_AARCH64', if_true: files('arm-cpu-models.c')) +arm_system_ss.add(when: 'CONFIG_KVM', + if_true: files('hyp_gdbstub.c', + 'kvm.c')) arm_system_ss.add(when: 'CONFIG_HVF', if_true: files('hyp_gdbstub.c')) arm_user_ss.add(files('cpu.c'))
Thanks
Eric
Re: [RFC PATCH v3 09/19] target/arm: Add named cpu model infra + graviton3 named model
Quoted 26 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Hi Khushit,
Quoted 14 lines · Khushit Shah
From: Shaju Abraham <[email protected]>
Introduce a small named-CPU-model layer on top of the field-backed property infrastructure. Each model is a flat table of (name, value) overrides and a parent pointer. At instance-init, the parent chain is walked root-first and every level's properties are applied via QOM, so a child entry overrides its ancestors for the same name.
For example, the graviton3-v1 named model hierarchy is:
non-zero-defaults-v1 Known non-zero default ID regs field valuesarm-v8_4-a-v1 ARMv8.4-A architectural mandate neoverse-v1-v1 Neoverse V1 graviton3-v1 AWS Graviton3
Quoted 4 lines
Quoted 2 lines
non-zero-defaults-v1:
Field that should be populated with some non zero value by default.following which specification? This is not clear to me. Is that layer really meaningful? Shouldn't we start with the next one?
Okay, makes sense. We can get rid of this layer.
Quoted 77 lines
Quoted 66 lines
arm-v8_4-a-v1:
Only features mandated by the ARM ARM.neoverse-v1-v1:
Reference manual derived feature values for the reference core. Values differ from TRM values based on what was exposed to the guest with -cpu host.graviton3-v1:
SoC integration choices (crypto pin, cache hints, PAuth alg).The model values are figured out from ID register dump visible to QEMU with -cpu host on Graviton3 machine.
Model realization:
1. Zero out ID regs array.
2. Add all properties to the CPU Object
3.arm_realize_model_chain: Walk the parent chain from root first and apply all the properties.Co-authored-by Shaju Abraham <[email protected]>Signed-off-by Khushit Shah <[email protected]>---
hw/arm/virt.c | 5 + target/arm/arm-cpu-models.c | 336 ++++++++++++++++++++++++++++++++++++ target/arm/arm-cpu-models.h | 35 ++++ target/arm/meson.build | 7 +- 4 files changed, 381 insertions(+), 2 deletions(-)create mode 100644
target/arm/arm-cpu-models.c
create mode 100644target/arm/arm-cpu-models.hhw/arm/virt.c +5
-0@@ -3812,6 +3812,11 @@ static GPtrArray *virt_get_valid_cpu_types(const MachineState *ms)g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("host" ))); } } +if (kvm_enabled () &&target_aarch64 ()) { +g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("arm-v8_4-a-v1" ))); +g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("neoverse-v1-v1" ))); +g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("graviton3-v1" ))); + } g_ptr_array_add(vct, g_strdup(ARM_CPU_TYPE_NAME("max"))); return vct; diff --git a/target/arm/arm-cpu-models.c
b/target/arm/arm-cpu-models.cnew file mode 100644 index 0000000000..747e0df010 ---/dev/null+++b/target/arm/arm-cpu-models.chw/arm/virt.c +0
-0@@ -0,0 +1,336 @@ +/* + * ARM named CPU model definitions. + * + *Each model is defined as an array of
MODEL_PROPmacro, listing only +
* the properties that DIFFER from the parent model. + * + * At realisation the parent chain is walked root-first and + * every level's props are applied via QOM, so the leaf's values + * naturally override its ancestors. + * + * Hierarchy: + * + * non-zero-defaults-v1 Known non-zero default ID reg field values + * arm-v8_4-a-v1 ARMv8.4-A architectural mandate + * neoverse-v1-v1 Neoverse V1 (TRM 102649) + * graviton3-v1 AWS Graviton3 + * + *
SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h"hw/arm/virt.c +8
-0+#include "qapi/error.h" +#include "qemu/error-report.h" +#include "system/kvm.h" +#include "cpu.h" +#include "internals.h" +#include "kvm_arm.h" +#include "arm-cpu-models.h" +#include "cpu-idregs.h" hw/arm/virt.c
Quoted 10 lines
hw/arm/virt.c +10
-0+ +#define MODEL_PROP_FIELD_STR str +#define MODEL_PROP_FIELD_BOOL b +#define MODEL_PROP_FIELD_NUM num + +#define MODEL_PROP (_name, _type, _value) \ + { .name = (_name), .type = ARM_MODEL_PROP_##_type, \ + .u.MODEL_PROP_FIELD_##_type = (_value) } + +#define MODEL_PROP_END { .name = NULL }
Quoted 7 lines
Regarding settings somehow we end up with something that is quite similar to TCG CPU
definitions like inaarch64_neoverse_n1_initfn(). To me this is in general more readable because we use name fields instead of putting the full reg value. This does not prevent us from adding comments along settings to make this more readable and explicit.
Can you please specify further on what types of comments? Like what does each property value means?
Quoted 8 lines
Quoted 8 lines
hw/arm/virt.c +8
-0+ +/* +* These fields should be populated with some non-zero default values. +*/ +static const ArmModelPropValue non_zero_defaults_v1_props[] = { +/* ID_AA64PFR0_EL1 */ +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_EL0" ,NUM ,0b0001 ), +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_EL1" ,NUM ,0b0001 ),
Quoted 8 lines
hw/arm/virt.c
Quoted 5 lines
hw/arm/virt.c +5
-0+MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_FP" ,NUM ,0b1111 ), +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_AdvSIMD" ,NUM ,0b1111 ), + +/* ID_AA64PFR1_EL1 */ + MODEL_PROP("SYSREG_ID_AA64PFR1_EL1_MTE_frac", NUM, 0b1111),so I still believe we want a wrapper that transparently either sets a prop if the field happens to be writable or simply performs checks against the host if the prop is not available.
Can’t we do that easily afterwards once the ID reg view is finalised? Doing it here means all the qmp paths which do not intend to actually create any vCPUs will error out here, which is undesirable.
Quoted 18 lines
Quoted 18 lines
hw/arm/virt.c +18
-0+ +/* ID_AA64MMFR0_EL1 */ +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran64" ,NUM ,0b1111 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran4" ,NUM ,0b1111 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran16_2" ,NUM ,0b0001 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran64_2" ,NUM ,0b0001 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran4_2" ,NUM ,0b0001 ), + +/* ID_AA64DFR0_EL1 */ +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_DebugVer" ,NUM ,0x6 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_DoubleLock" ,NUM ,0b1111 ), + +/* CTR_EL0 */ +MODEL_PROP ("SYSREG_CTR_EL0_L1Ip" ,NUM ,0b10 ), +MODEL_PROP ("SYSREG_CTR_EL0_RES1_31" ,NUM ,1 ), + +/* ID_AA64MMFR4_EL1 */ + MODEL_PROP("SYSREG_ID_AA64MMFR4_EL1_E2H0", NUM, 0b1111),
Quoted 8 lines
hw/arm/virt.c
Quoted 3 lines
hw/arm/virt.c +3
-0+ + MODEL_PROP_END, +};To ease the review I would suggest to put a dump of all id regs of a leaf model in the commit description. It is less error prone that understanding the various overrides.
I would suggest to have separate patches for each model too.
Ack to both. Will do this in v4.
Quoted 3 lines
So you said a leaf model shall have explicit values for each field, including non writable ones. The code does not check that. How do we make sure we are not missing settings?
I am not sure where I say that, assumption is:
Base model starts with a zeroed IO reg view, each model in chain applies some settings, a child model’s setting overrides parents’ settings.
For verification we can dump the leaf ID regs view, it should match with the one in the commit message as per your suggestion.
Quoted 332 lines
Quoted 319 lines
hw/arm/virt.c +263
-0+ +static const ArmModelPropValue armv8_4_a_v1_props[] = { +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_CRC32" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_Atomic" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_HPDS" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_LO" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_DPB" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_RAS" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_RAS_frac" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_PAN" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_UAO" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_CnP" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_IESB" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_DIT" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_DebugVer" ,NUM ,9 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_PMUVer" ,NUM ,5 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_TS" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_LRCPC" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_AT" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_IDS" ,NUM ,1 ), +/* KVM zeroes out these field when MTE is not enabled. */ +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_MTE_frac" ,NUM ,0 ), +MODEL_PROP_END , +}; + +static const ArmModelPropValue neoverse_v1_v1_props[] = { +MODEL_PROP ("SYSREG_MIDR_EL1_Implementer" ,NUM ,0x41 ), +MODEL_PROP ("SYSREG_MIDR_EL1_Variant" ,NUM ,0x1 ), +MODEL_PROP ("SYSREG_MIDR_EL1_Architecture" ,NUM ,0xF ), +MODEL_PROP ("SYSREG_MIDR_EL1_PartNum" ,NUM ,0xD40 ), +MODEL_PROP ("SYSREG_MIDR_EL1_Revision" ,NUM ,0x1 ), + +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_BRPs" ,NUM ,0x5 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_WRPs" ,NUM ,0x3 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_CTX_CMPs" ,NUM ,0x1 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_DoubleLock" ,NUM ,0xF ), + +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_RDM" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_DP" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_FHM" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_DPB" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_JSCVT" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_FCMA" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_BF16" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_DGH" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_I8MM" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_FP" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_AdvSIMD" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_RAS" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_RAS_frac" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_CSV2" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_CSV2_frac" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_CSV3" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_SSBS" ,NUM ,2 ), + +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_PARange" ,NUM ,5 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_ASIDBits" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_BigEnd" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_SNSMem" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran4" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran16" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran64" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran4_2" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran16_2" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran64_2" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_HAFDBS" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_VMIDBits" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_VH" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_HPDS" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_XNX" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_SpecSEI" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_FWB" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_BBM" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_EVT" ,NUM ,2 ), + +MODEL_PROP ("SYSREG_ID_AA64MMFR4_EL1_E2H0" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_CTR_EL0_IminLine" ,NUM ,4 ), +MODEL_PROP ("SYSREG_CTR_EL0_L1Ip" ,NUM ,3 ), +MODEL_PROP ("SYSREG_CTR_EL0_DminLine" ,NUM ,4 ), +MODEL_PROP ("SYSREG_CTR_EL0_ERG" ,NUM ,4 ), +MODEL_PROP ("SYSREG_CTR_EL0_CWG" ,NUM ,4 ), + +MODEL_PROP ("SYSREG_DCZID_EL0_BS" ,NUM ,0x4 ), + +/* pauth */ +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_APA" ,NUM ,3 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_GPA" ,NUM ,1 ), + +/* sve */ +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_SVE" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ZFR0_EL1_BF16" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ZFR0_EL1_I8MM" ,NUM ,1 ), +MODEL_PROP ("sve128" ,BOOL , true), + +MODEL_PROP_END , +}; + +static const ArmModelPropValue graviton3_v1_props[] = { +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_AES" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SHA1" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SHA2" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SHA3" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SM3" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SM4" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_RNDR" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_CTR_EL0_IDC" ,NUM ,1 ), +MODEL_PROP ("SYSREG_CTR_EL0_DIC" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_REVIDR_EL1_VAL" ,NUM ,1 ), + +MODEL_PROP_END , +}; + +static const ArmNamedCpuModel arm_cpu_models[] = { + { + .name ="non-zero-defaults-v1" , + .parent =NULL , + .props = non_zero_defaults_v1_props, + }, + { + .name ="arm-v8_4-a-v1" , + .parent ="non-zero-defaults-v1" , + .props = armv8_4_a_v1_props, + }, + { + .name ="neoverse-v1-v1" , + .parent ="arm-v8_4-a-v1" , + .props = neoverse_v1_v1_props, + }, + { + .name ="graviton3-v1" , + .parent ="neoverse-v1-v1" , + .props = graviton3_v1_props, + }, +}; + +static ARMCPUInfo arm_named_cpu_infos[ARRAY_SIZE (arm_cpu_models)]; +const ArmNamedCpuModel *arm_find_model (const char *name) +{ +size_t i; +for (i =0 ; i <ARRAY_SIZE (arm_cpu_models); i++) { +if (g_str_equal (arm_cpu_models[i].name, name)) { +return &arm_cpu_models[i]; + } + } +return NULL ; +} + +static void arm_apply_model_props (Object *obj,const ArmModelPropValue *props, +Error **errp) +{ +const ArmModelPropValue *pv; +ERRP_GUARD (); + +for (pv = props; pv->name; pv++) { +switch (pv->type) { +case ARM_MODEL_PROP_BOOL : +object_property_set_bool (obj, pv->name, pv->u.b, errp); +break ; +case ARM_MODEL_PROP_NUM : +object_property_set_uint (obj, pv->name, pv->u.num, errp); +break ; +default : +g_assert_not_reached (); + } +if (*errp) { +error_prepend (errp,"property '%s': " , pv->name); +return ; + } + } +} + +static void arm_realize_model_chain (Object *obj,const ArmNamedCpuModel *model, +Error **errp) +{ +const ArmNamedCpuModel *cur, *parent; +const ArmNamedCpuModel *chain[ARRAY_SIZE (arm_cpu_models)]; +size_t depth =0 ; +for (cur = model; cur; ) { +if (depth >=ARRAY_SIZE (chain)) { +error_setg (errp,"model '%s': parent chain too deep " +"(possible cycle)" , model->name); +return ; + } + chain[depth++] = cur; + +if (!cur->parent) { +break ; + } + parent =arm_find_model (cur->parent); +if (!parent) { +error_setg (errp,"model '%s': unknown parent '%s'" , + cur->name, cur->parent); +return ; + } + cur = parent; + } + +while (depth--) { +arm_apply_model_props (obj, chain[depth]->props, errp); +if (*errp) { +return ; + } + } +} + +static void arm_named_cpu_initfn (Object *obj) +{ +ARMCPU *cpu =ARM_CPU (obj); +ARMCPUClass *acc =ARM_CPU_GET_CLASS (obj); +const ArmNamedCpuModel *model =arm_find_model (acc->info->name); +if (!model) { +error_report ("'%s' CPU model entry not found)" , + acc->info->name); +return ; + } + +if (!kvm_enabled ()) { +error_report ("'%s' CPU model requires KVM (-accel kvm)" , + acc->info->name); +return ; + } + +kvm_arm_set_cpu_features_from_host (cpu); +if (!arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) { +return ; + } + +/* 1. Reset ID regs to 0 */ +memset (cpu->isar.idregs,0 ,sizeof (cpu->isar.idregs)); + +/* 2. Add sveNNNN and SYSREG_ properties */ +aarch64_add_sve_properties (obj); +aarch64_add_idregs_properties (obj); + +/* 3. Realize the model chain. */ +arm_realize_model_chain (obj, model, &error_abort); +} + +void arm_register_named_cpu_models (void ) +{ +size_t i; +for (i =0 ; i <ARRAY_SIZE (arm_cpu_models); i++) { + arm_named_cpu_infos[i].name = arm_cpu_models[i].name; + arm_named_cpu_infos[i].initfn = arm_named_cpu_initfn; +arm_cpu_register (&arm_named_cpu_infos[i]); + } +} + +type_init (arm_register_named_cpu_models)target/arm/arm-cpu-models.h new file +35
-0@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* ARM named CPU model definitions - public API. +*/ +#ifndef ARM_CPU_MODELS_H +#define ARM_CPU_MODELS_H + +#include "qapi/error.h" +#include "qom/object.h" + +typedef enum ArmModelPropType { +ARM_MODEL_PROP_BOOL , +ARM_MODEL_PROP_NUM , +}ArmModelPropType ; + +typedef struct ArmModelPropValue { +const char *name; +ArmModelPropType type; +union { +bool b; +uint64_t num; + } u; +}ArmModelPropValue ; + +typedef struct ArmNamedCpuModel { +const char *name; +const char *parent; +const ArmModelPropValue *props; +}ArmNamedCpuModel ; + +void arm_register_named_cpu_models (void ); + +const ArmNamedCpuModel *arm_find_model (const char *name); + +#endif /* ARM_CPU_MODELS_H */ target/arm/meson.build +0
-0@@ -10,7 +10,7 @@ arm_user_ss.add(files('gdbstub.c'))arm_ss.add(when: '
TARGET_AARCH64',if_true: files(
'cpu64.c',target/arm/meson.build +1
-1- 'gdbstub64.c' + 'gdbstub64.c',))
arm_common_ss.add(files(
target/arm/meson.build +0
-0@@ -21,7 +21,10 @@ arm_common_system_ss.add(files( 'arm-qmp-cmds.c',target/arm/meson.build arm_common_system_ss.add(files( · line 30
Quoted 10 lines
target/arm/meson.build +4
-1'cpu-idregs.c', )) -arm_system_ss.add(when: 'CONFIG_KVM', if_true: files('hyp_gdbstub.c', 'kvm.c')) +arm_system_ss.add(when: 'TARGET_AARCH64', if_true: files('arm-cpu-models.c')) +arm_system_ss.add(when: 'CONFIG_KVM', + if_true: files('hyp_gdbstub.c', + 'kvm.c')) arm_system_ss.add(when: 'CONFIG_HVF', if_true: files('hyp_gdbstub.c')) arm_user_ss.add(files('cpu.c'))Thanks
Eric
Re: [RFC PATCH v3 09/19] target/arm: Add named cpu model infra + graviton3 named model
Quoted 113 lines · Khushit Shah
Quoted 25 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Hi Khushit,
Quoted 14 lines · Khushit Shah
From: Shaju Abraham <[email protected]>
Introduce a small named-CPU-model layer on top of the field-backed property infrastructure. Each model is a flat table of (name, value) overrides and a parent pointer. At instance-init, the parent chain is walked root-first and every level's properties are applied via QOM, so a child entry overrides its ancestors for the same name.
For example, the graviton3-v1 named model hierarchy is:
non-zero-defaults-v1 Known non-zero default ID regs field valuesarm-v8_4-a-v1 ARMv8.4-A architectural mandate neoverse-v1-v1 Neoverse V1 graviton3-v1 AWS Graviton3Quoted 4 lines
Quoted 2 lines
non-zero-defaults-v1:
Field that should be populated with some non zero value by default.following which specification? This is not clear to me. Is that layer really meaningful? Shouldn't we start with the next one?
Okay, makes sense. We can get rid of this layer.
Quoted 74 lines
Quoted 74 lines
arm-v8_4-a-v1:
Only features mandated by the ARM ARM.neoverse-v1-v1:
Reference manual derived feature values for the reference core. Values differ from TRM values based on what was exposed to the guest with -cpu host.graviton3-v1:
SoC integration choices (crypto pin, cache hints, PAuth alg).The model values are figured out from ID register dump visible to QEMU with -cpu host on Graviton3 machine.
Model realization:
1. Zero out ID regs array.
2. Add all properties to the CPU Object
3.arm_realize_model_chain: Walk the parent chain from root first and apply all the properties.Co-authored-by Shaju Abraham <[email protected]>Signed-off-by Khushit Shah <[email protected]>---
hw/arm/virt.c | 5 + target/arm/arm-cpu-models.c | 336 ++++++++++++++++++++++++++++++++++++ target/arm/arm-cpu-models.h | 35 ++++ target/arm/meson.build | 7 +- 4 files changed, 381 insertions(+), 2 deletions(-)create mode 100644
target/arm/arm-cpu-models.c
create mode 100644target/arm/arm-cpu-models.hhw/arm/virt.c +5
-0@@ -3812,6 +3812,11 @@ static GPtrArray *virt_get_valid_cpu_types(const MachineState *ms)g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("host" ))); } } +if (kvm_enabled () &&target_aarch64 ()) { +g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("arm-v8_4-a-v1" ))); +g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("neoverse-v1-v1" ))); +g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("graviton3-v1" ))); + } g_ptr_array_add(vct, g_strdup(ARM_CPU_TYPE_NAME("max"))); return vct; diff --git a/target/arm/arm-cpu-models.c
b/target/arm/arm-cpu-models.cnew file mode 100644 index 0000000000..747e0df010 ---/dev/null+++b/target/arm/arm-cpu-models.chw/arm/virt.c +0
-0@@ -0,0 +1,336 @@ +/* + * ARM named CPU model definitions. + * + *Each model is defined as an array of
MODEL_PROPmacro, listing only +
* the properties that DIFFER from the parent model. + * + * At realisation the parent chain is walked root-first and + * every level's props are applied via QOM, so the leaf's values + * naturally override its ancestors. + * + * Hierarchy: + * + * non-zero-defaults-v1 Known non-zero default ID reg field values + * arm-v8_4-a-v1 ARMv8.4-A architectural mandate + * neoverse-v1-v1 Neoverse V1 (TRM 102649) + * graviton3-v1 AWS Graviton3 + * + *
SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h"hw/arm/virt.c +17
-0+#include "qapi/error.h" +#include "qemu/error-report.h" +#include "system/kvm.h" +#include "cpu.h" +#include "internals.h" +#include "kvm_arm.h" +#include "arm-cpu-models.h" +#include "cpu-idregs.h" + +#define MODEL_PROP_FIELD_STR str +#define MODEL_PROP_FIELD_BOOL b +#define MODEL_PROP_FIELD_NUM num + +#define MODEL_PROP (_name, _type, _value) \ + { .name = (_name), .type = ARM_MODEL_PROP_##_type, \ + .u.MODEL_PROP_FIELD_##_type = (_value) } +Quoted 8 lines
Quoted 1 line
+#define
MODEL_PROP_END{ .name = NULL }Regarding settings somehow we end up with something that is quite similar to TCG CPU
definitions like inaarch64_neoverse_n1_initfn(). To me this is in general more readable because we use name fields instead of putting the full reg value. This does not prevent us from adding comments along settings to make this more readable and explicit.
Quoted 2 lines
Can you please specify further on what types of comments? Like what does each property value means?
yes, something alike what is done when we populate acpi table fields
Quoted 17 lines
Quoted 17 lines
Quoted 4 lines
hw/arm/virt.c +3
-0+ +/* +* These fields should be populated with some non-zero default values. hw/arm/virt.c
Quoted 10 lines
hw/arm/virt.c +10
-0+*/ +static const ArmModelPropValue non_zero_defaults_v1_props[] = { +/* ID_AA64PFR0_EL1 */ +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_EL0" ,NUM ,0b0001 ), +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_EL1" ,NUM ,0b0001 ), +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_FP" ,NUM ,0b1111 ), +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_AdvSIMD" ,NUM ,0b1111 ), + +/* ID_AA64PFR1_EL1 */ +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_MTE_frac" ,NUM ,0b1111 ),so I still believe we want a wrapper that transparently either sets a prop if the field happens to be writable or simply performs checks against the host if the prop is not available.
Quoted 3 lines
Can’t we do that easily afterwards once the ID reg view is finalised? Doing it here means all the qmp paths which do not intend to actually create any vCPUs will error out here, which is undesirable.
sorry but I don't catch
Quoted 28 lines
Quoted 18 lines
Quoted 18 lines
hw/arm/virt.c +17
-0+ +/* ID_AA64MMFR0_EL1 */ +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran64" ,NUM ,0b1111 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran4" ,NUM ,0b1111 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran16_2" ,NUM ,0b0001 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran64_2" ,NUM ,0b0001 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran4_2" ,NUM ,0b0001 ), + +/* ID_AA64DFR0_EL1 */ +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_DebugVer" ,NUM ,0x6 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_DoubleLock" ,NUM ,0b1111 ), + +/* CTR_EL0 */ +MODEL_PROP ("SYSREG_CTR_EL0_L1Ip" ,NUM ,0b10 ), +MODEL_PROP ("SYSREG_CTR_EL0_RES1_31" ,NUM ,1 ), + + /* ID_AA64MMFR4_EL1 */Quoted 8 lines
hw/arm/virt.c
Quoted 4 lines
hw/arm/virt.c +4
-0+MODEL_PROP ("SYSREG_ID_AA64MMFR4_EL1_E2H0" ,NUM ,0b1111 ), + + MODEL_PROP_END, +};To ease the review I would suggest to put a dump of all id regs of a leaf model in the commit description. It is less error prone that understanding the various overrides.
I would suggest to have separate patches for each model too.Ack to both. Will do this in v4.
Quoted 7 lines
Quoted 3 lines
So you said a leaf model shall have explicit values for each field, including non writable ones. The code does not check that. How do we make sure we are not missing settings?
I am not sure where I say that, assumption is:
Base model starts with a zeroed IO reg view, each model in chain applies some settings, a child model’s setting overrides parents’ settings.
Ah ok I must have misunderstood then.
Quoted 337 lines
For verification we can dump the leaf ID regs view, it should match with the one in the commit message as per your suggestion.
Quoted 332 lines
Quoted 319 lines
hw/arm/virt.c +263
-0+ +static const ArmModelPropValue armv8_4_a_v1_props[] = { +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_CRC32" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_Atomic" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_HPDS" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_LO" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_DPB" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_RAS" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_RAS_frac" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_PAN" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_UAO" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_CnP" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_IESB" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_DIT" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_DebugVer" ,NUM ,9 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_PMUVer" ,NUM ,5 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_TS" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_LRCPC" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_AT" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_IDS" ,NUM ,1 ), +/* KVM zeroes out these field when MTE is not enabled. */ +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_MTE_frac" ,NUM ,0 ), +MODEL_PROP_END , +}; + +static const ArmModelPropValue neoverse_v1_v1_props[] = { +MODEL_PROP ("SYSREG_MIDR_EL1_Implementer" ,NUM ,0x41 ), +MODEL_PROP ("SYSREG_MIDR_EL1_Variant" ,NUM ,0x1 ), +MODEL_PROP ("SYSREG_MIDR_EL1_Architecture" ,NUM ,0xF ), +MODEL_PROP ("SYSREG_MIDR_EL1_PartNum" ,NUM ,0xD40 ), +MODEL_PROP ("SYSREG_MIDR_EL1_Revision" ,NUM ,0x1 ), + +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_BRPs" ,NUM ,0x5 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_WRPs" ,NUM ,0x3 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_CTX_CMPs" ,NUM ,0x1 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_DoubleLock" ,NUM ,0xF ), + +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_RDM" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_DP" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_FHM" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_DPB" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_JSCVT" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_FCMA" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_BF16" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_DGH" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_I8MM" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_FP" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_AdvSIMD" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_RAS" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_RAS_frac" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_CSV2" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_CSV2_frac" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_CSV3" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_SSBS" ,NUM ,2 ), + +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_PARange" ,NUM ,5 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_ASIDBits" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_BigEnd" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_SNSMem" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran4" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran16" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran64" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran4_2" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran16_2" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran64_2" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_HAFDBS" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_VMIDBits" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_VH" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_HPDS" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_XNX" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_SpecSEI" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_FWB" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_BBM" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_EVT" ,NUM ,2 ), + +MODEL_PROP ("SYSREG_ID_AA64MMFR4_EL1_E2H0" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_CTR_EL0_IminLine" ,NUM ,4 ), +MODEL_PROP ("SYSREG_CTR_EL0_L1Ip" ,NUM ,3 ), +MODEL_PROP ("SYSREG_CTR_EL0_DminLine" ,NUM ,4 ), +MODEL_PROP ("SYSREG_CTR_EL0_ERG" ,NUM ,4 ), +MODEL_PROP ("SYSREG_CTR_EL0_CWG" ,NUM ,4 ), + +MODEL_PROP ("SYSREG_DCZID_EL0_BS" ,NUM ,0x4 ), + +/* pauth */ +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_APA" ,NUM ,3 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_GPA" ,NUM ,1 ), + +/* sve */ +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_SVE" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ZFR0_EL1_BF16" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ZFR0_EL1_I8MM" ,NUM ,1 ), +MODEL_PROP ("sve128" ,BOOL , true), + +MODEL_PROP_END , +}; + +static const ArmModelPropValue graviton3_v1_props[] = { +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_AES" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SHA1" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SHA2" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SHA3" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SM3" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SM4" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_RNDR" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_CTR_EL0_IDC" ,NUM ,1 ), +MODEL_PROP ("SYSREG_CTR_EL0_DIC" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_REVIDR_EL1_VAL" ,NUM ,1 ), + +MODEL_PROP_END , +}; + +static const ArmNamedCpuModel arm_cpu_models[] = { + { + .name ="non-zero-defaults-v1" , + .parent =NULL , + .props = non_zero_defaults_v1_props, + }, + { + .name ="arm-v8_4-a-v1" , + .parent ="non-zero-defaults-v1" , + .props = armv8_4_a_v1_props, + }, + { + .name ="neoverse-v1-v1" , + .parent ="arm-v8_4-a-v1" , + .props = neoverse_v1_v1_props, + }, + { + .name ="graviton3-v1" , + .parent ="neoverse-v1-v1" , + .props = graviton3_v1_props, + }, +}; + +static ARMCPUInfo arm_named_cpu_infos[ARRAY_SIZE (arm_cpu_models)]; +const ArmNamedCpuModel *arm_find_model (const char *name) +{ +size_t i; +for (i =0 ; i <ARRAY_SIZE (arm_cpu_models); i++) { +if (g_str_equal (arm_cpu_models[i].name, name)) { +return &arm_cpu_models[i]; + } + } +return NULL ; +} + +static void arm_apply_model_props (Object *obj,const ArmModelPropValue *props, +Error **errp) +{ +const ArmModelPropValue *pv; +ERRP_GUARD (); + +for (pv = props; pv->name; pv++) { +switch (pv->type) { +case ARM_MODEL_PROP_BOOL : +object_property_set_bool (obj, pv->name, pv->u.b, errp); +break ; +case ARM_MODEL_PROP_NUM : +object_property_set_uint (obj, pv->name, pv->u.num, errp); +break ; +default : +g_assert_not_reached (); + } +if (*errp) { +error_prepend (errp,"property '%s': " , pv->name); +return ; + } + } +} + +static void arm_realize_model_chain (Object *obj,const ArmNamedCpuModel *model, +Error **errp) +{ +const ArmNamedCpuModel *cur, *parent; +const ArmNamedCpuModel *chain[ARRAY_SIZE (arm_cpu_models)]; +size_t depth =0 ; +for (cur = model; cur; ) { +if (depth >=ARRAY_SIZE (chain)) { +error_setg (errp,"model '%s': parent chain too deep " +"(possible cycle)" , model->name); +return ; + } + chain[depth++] = cur; + +if (!cur->parent) { +break ; + } + parent =arm_find_model (cur->parent); +if (!parent) { +error_setg (errp,"model '%s': unknown parent '%s'" , + cur->name, cur->parent); +return ; + } + cur = parent; + } + +while (depth--) { +arm_apply_model_props (obj, chain[depth]->props, errp); +if (*errp) { +return ; + } + } +} + +static void arm_named_cpu_initfn (Object *obj) +{ +ARMCPU *cpu =ARM_CPU (obj); +ARMCPUClass *acc =ARM_CPU_GET_CLASS (obj); +const ArmNamedCpuModel *model =arm_find_model (acc->info->name); +if (!model) { +error_report ("'%s' CPU model entry not found)" , + acc->info->name); +return ; + } + +if (!kvm_enabled ()) { +error_report ("'%s' CPU model requires KVM (-accel kvm)" , + acc->info->name); +return ; + } + +kvm_arm_set_cpu_features_from_host (cpu); +if (!arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) { +return ; + } + +/* 1. Reset ID regs to 0 */ +memset (cpu->isar.idregs,0 ,sizeof (cpu->isar.idregs)); + +/* 2. Add sveNNNN and SYSREG_ properties */ +aarch64_add_sve_properties (obj); +aarch64_add_idregs_properties (obj); + +/* 3. Realize the model chain. */ +arm_realize_model_chain (obj, model, &error_abort); +} + +void arm_register_named_cpu_models (void ) +{ +size_t i; +for (i =0 ; i <ARRAY_SIZE (arm_cpu_models); i++) { + arm_named_cpu_infos[i].name = arm_cpu_models[i].name; + arm_named_cpu_infos[i].initfn = arm_named_cpu_initfn; +arm_cpu_register (&arm_named_cpu_infos[i]); + } +} + +type_init (arm_register_named_cpu_models)target/arm/arm-cpu-models.h new file +35
-0@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* ARM named CPU model definitions - public API. +*/ +#ifndef ARM_CPU_MODELS_H +#define ARM_CPU_MODELS_H + +#include "qapi/error.h" +#include "qom/object.h" + +typedef enum ArmModelPropType { +ARM_MODEL_PROP_BOOL , +ARM_MODEL_PROP_NUM , +}ArmModelPropType ; + +typedef struct ArmModelPropValue { +const char *name; +ArmModelPropType type; +union { +bool b; +uint64_t num; + } u; +}ArmModelPropValue ; + +typedef struct ArmNamedCpuModel { +const char *name; +const char *parent; +const ArmModelPropValue *props; +}ArmNamedCpuModel ; + +void arm_register_named_cpu_models (void ); + +const ArmNamedCpuModel *arm_find_model (const char *name); + +#endif /* ARM_CPU_MODELS_H */ target/arm/meson.build +0
-0@@ -10,7 +10,7 @@ arm_user_ss.add(files('gdbstub.c'))arm_ss.add(when: '
TARGET_AARCH64',if_true: files(
'cpu64.c',target/arm/meson.build +1
-1- 'gdbstub64.c' + 'gdbstub64.c',))
arm_common_ss.add(files(
target/arm/meson.build +0
-0@@ -21,7 +21,10 @@ arm_common_system_ss.add(files( 'arm-qmp-cmds.c',target/arm/meson.build arm_common_system_ss.add(files( · line 30
Quoted 10 lines
target/arm/meson.build +4
-1'cpu-idregs.c', )) -arm_system_ss.add(when: 'CONFIG_KVM', if_true: files('hyp_gdbstub.c', 'kvm.c')) +arm_system_ss.add(when: 'TARGET_AARCH64', if_true: files('arm-cpu-models.c')) +arm_system_ss.add(when: 'CONFIG_KVM', + if_true: files('hyp_gdbstub.c', + 'kvm.c')) arm_system_ss.add(when: 'CONFIG_HVF', if_true: files('hyp_gdbstub.c')) arm_user_ss.add(files('cpu.c'))Thanks
Eric
Thanks
Eric
Re: [RFC PATCH v3 09/19] target/arm: Add named cpu model infra + graviton3 named model
Quoted 125 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 113 lines · Khushit Shah
Quoted 25 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Hi Khushit,
Quoted 14 lines · Khushit Shah
From: Shaju Abraham <[email protected]>
Introduce a small named-CPU-model layer on top of the field-backed property infrastructure. Each model is a flat table of (name, value) overrides and a parent pointer. At instance-init, the parent chain is walked root-first and every level's properties are applied via QOM, so a child entry overrides its ancestors for the same name.
For example, the graviton3-v1 named model hierarchy is:
non-zero-defaults-v1 Known non-zero default ID regs field valuesarm-v8_4-a-v1 ARMv8.4-A architectural mandate neoverse-v1-v1 Neoverse V1 graviton3-v1 AWS Graviton3Quoted 4 lines
Quoted 2 lines
non-zero-defaults-v1:
Field that should be populated with some non zero value by default.following which specification? This is not clear to me. Is that layer really meaningful? Shouldn't we start with the next one?
Okay, makes sense. We can get rid of this layer.
Quoted 82 lines
Quoted 65 lines
arm-v8_4-a-v1:
Only features mandated by the ARM ARM.neoverse-v1-v1:
Reference manual derived feature values for the reference core. Values differ from TRM values based on what was exposed to the guest with -cpu host.graviton3-v1:
SoC integration choices (crypto pin, cache hints, PAuth alg).The model values are figured out from ID register dump visible to QEMU with -cpu host on Graviton3 machine.
Model realization:
1. Zero out ID regs array.
2. Add all properties to the CPU Object
3.arm_realize_model_chain: Walk the parent chain from root first and apply all the properties.Co-authored-by Shaju Abraham <[email protected]>Signed-off-by Khushit Shah <[email protected]>---
hw/arm/virt.c | 5 + target/arm/arm-cpu-models.c | 336 ++++++++++++++++++++++++++++++++++++ target/arm/arm-cpu-models.h | 35 ++++ target/arm/meson.build | 7 +- 4 files changed, 381 insertions(+), 2 deletions(-)create mode 100644
target/arm/arm-cpu-models.c
create mode 100644target/arm/arm-cpu-models.hhw/arm/virt.c +5
-0@@ -3812,6 +3812,11 @@ static GPtrArray *virt_get_valid_cpu_types(const MachineState *ms)g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("host" ))); } } +if (kvm_enabled () &&target_aarch64 ()) { +g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("arm-v8_4-a-v1" ))); +g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("neoverse-v1-v1" ))); +g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("graviton3-v1" ))); + } g_ptr_array_add(vct, g_strdup(ARM_CPU_TYPE_NAME("max"))); return vct; diff --git a/target/arm/arm-cpu-models.c
b/target/arm/arm-cpu-models.cnew file mode 100644 index 0000000000..747e0df010 ---/dev/null+++b/target/arm/arm-cpu-models.chw/arm/virt.c +0
-0@@ -0,0 +1,336 @@ +/* + * ARM named CPU model definitions. + * + *Each model is defined as an array of
MODEL_PROPmacro, listing only +
* the properties that DIFFER from the parent model. + * + * At realisation the parent chain is walked root-first and + * every level's props are applied via QOM, so the leaf's values + * naturally override its ancestors. + * + * Hierarchy: + * + * non-zero-defaults-v1 Known non-zero default ID reg field values + * arm-v8_4-a-v1 ARMv8.4-A architectural mandate + * neoverse-v1-v1 Neoverse V1 (TRM 102649) + * graviton3-v1 AWS Graviton3 + * + *
SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h"hw/arm/virt.c +8
-0+#include "qapi/error.h" +#include "qemu/error-report.h" +#include "system/kvm.h" +#include "cpu.h" +#include "internals.h" +#include "kvm_arm.h" +#include "arm-cpu-models.h" +#include "cpu-idregs.h" hw/arm/virt.c
Quoted 10 lines
hw/arm/virt.c +10
-0+ +#define MODEL_PROP_FIELD_STR str +#define MODEL_PROP_FIELD_BOOL b +#define MODEL_PROP_FIELD_NUM num + +#define MODEL_PROP (_name, _type, _value) \ + { .name = (_name), .type = ARM_MODEL_PROP_##_type, \ + .u.MODEL_PROP_FIELD_##_type = (_value) } + +#define MODEL_PROP_END { .name = NULL }Regarding settings somehow we end up with something that is quite similar to TCG CPU
definitions like inaarch64_neoverse_n1_initfn(). To me this is in general more readable because we use name fields instead of putting the full reg value. This does not prevent us from adding comments along settings to make this more readable and explicit.
Quoted 3 lines
Quoted 2 lines
Can you please specify further on what types of comments? Like what does each property value means?
yes, something alike what is done when we populate acpi table fields
Acked.
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 4 lines
hw/arm/virt.c +3
-0+ +/* +* These fields should be populated with some non-zero default values. hw/arm/virt.c
Quoted 10 lines
hw/arm/virt.c +10
-0+*/ +static const ArmModelPropValue non_zero_defaults_v1_props[] = { +/* ID_AA64PFR0_EL1 */ +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_EL0" ,NUM ,0b0001 ), +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_EL1" ,NUM ,0b0001 ), +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_FP" ,NUM ,0b1111 ), +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_AdvSIMD" ,NUM ,0b1111 ), + +/* ID_AA64PFR1_EL1 */ +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_MTE_frac" ,NUM ,0b1111 ),so I still believe we want a wrapper that transparently either sets a prop if the field happens to be writable or simply performs checks against the host if the prop is not available.
Quoted 4 lines
Quoted 3 lines
Can’t we do that easily afterwards once the ID reg view is finalised? Doing it here means all the qmp paths which do not intend to actually create any vCPUs will error out here, which is undesirable.
sorry but I don't catch
For example, query-cpu-model-expansion {“model-a”, {props: {“fieldA”:
hostVal}} will error out on "model-a” realisation if “model-a”’s “fieldA” value is not compatible with host val. But we should not do that, we want to wait till the final state is ready (after applying user options) and then check problematic values.
Warm Regards,
Khushit
Quoted 375 lines
Quoted 27 lines
Quoted 17 lines
Quoted 17 lines
hw/arm/virt.c +17
-0+ +/* ID_AA64MMFR0_EL1 */ +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran64" ,NUM ,0b1111 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran4" ,NUM ,0b1111 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran16_2" ,NUM ,0b0001 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran64_2" ,NUM ,0b0001 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran4_2" ,NUM ,0b0001 ), + +/* ID_AA64DFR0_EL1 */ +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_DebugVer" ,NUM ,0x6 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_DoubleLock" ,NUM ,0b1111 ), + +/* CTR_EL0 */ +MODEL_PROP ("SYSREG_CTR_EL0_L1Ip" ,NUM ,0b10 ), +MODEL_PROP ("SYSREG_CTR_EL0_RES1_31" ,NUM ,1 ), + + /* ID_AA64MMFR4_EL1 */Quoted 8 lines
hw/arm/virt.c
Quoted 4 lines
hw/arm/virt.c +4
-0+MODEL_PROP ("SYSREG_ID_AA64MMFR4_EL1_E2H0" ,NUM ,0b1111 ), + + MODEL_PROP_END, +};To ease the review I would suggest to put a dump of all id regs of a leaf model in the commit description. It is less error prone that understanding the various overrides.
I would suggest to have separate patches for each model too.Ack to both. Will do this in v4.
Quoted 7 lines
Quoted 3 lines
So you said a leaf model shall have explicit values for each field, including non writable ones. The code does not check that. How do we make sure we are not missing settings?
I am not sure where I say that, assumption is:
Base model starts with a zeroed IO reg view, each model in chain applies some settings, a child model’s setting overrides parents’ settings.Ah ok I must have misunderstood then.
Quoted 337 lines
For verification we can dump the leaf ID regs view, it should match with the one in the commit message as per your suggestion.
Quoted 332 lines
Quoted 319 lines
hw/arm/virt.c +263
-0+ +static const ArmModelPropValue armv8_4_a_v1_props[] = { +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_CRC32" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_Atomic" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_HPDS" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_LO" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_DPB" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_RAS" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_RAS_frac" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_PAN" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_UAO" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_CnP" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_IESB" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_DIT" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_DebugVer" ,NUM ,9 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_PMUVer" ,NUM ,5 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_TS" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_LRCPC" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_AT" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_IDS" ,NUM ,1 ), +/* KVM zeroes out these field when MTE is not enabled. */ +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_MTE_frac" ,NUM ,0 ), +MODEL_PROP_END , +}; + +static const ArmModelPropValue neoverse_v1_v1_props[] = { +MODEL_PROP ("SYSREG_MIDR_EL1_Implementer" ,NUM ,0x41 ), +MODEL_PROP ("SYSREG_MIDR_EL1_Variant" ,NUM ,0x1 ), +MODEL_PROP ("SYSREG_MIDR_EL1_Architecture" ,NUM ,0xF ), +MODEL_PROP ("SYSREG_MIDR_EL1_PartNum" ,NUM ,0xD40 ), +MODEL_PROP ("SYSREG_MIDR_EL1_Revision" ,NUM ,0x1 ), + +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_BRPs" ,NUM ,0x5 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_WRPs" ,NUM ,0x3 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_CTX_CMPs" ,NUM ,0x1 ), +MODEL_PROP ("SYSREG_ID_AA64DFR0_EL1_DoubleLock" ,NUM ,0xF ), + +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_RDM" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_DP" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_FHM" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_DPB" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_JSCVT" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_FCMA" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_BF16" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_DGH" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_I8MM" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_FP" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_AdvSIMD" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_RAS" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_RAS_frac" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_CSV2" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_CSV2_frac" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_CSV3" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_ID_AA64PFR1_EL1_SSBS" ,NUM ,2 ), + +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_PARange" ,NUM ,5 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_ASIDBits" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_BigEnd" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_SNSMem" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran4" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran16" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran64" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran4_2" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran16_2" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR0_EL1_TGran64_2" ,NUM ,0 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_HAFDBS" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_VMIDBits" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_VH" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_HPDS" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_XNX" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR1_EL1_SpecSEI" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_FWB" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_BBM" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64MMFR2_EL1_EVT" ,NUM ,2 ), + +MODEL_PROP ("SYSREG_ID_AA64MMFR4_EL1_E2H0" ,NUM ,0 ), + +MODEL_PROP ("SYSREG_CTR_EL0_IminLine" ,NUM ,4 ), +MODEL_PROP ("SYSREG_CTR_EL0_L1Ip" ,NUM ,3 ), +MODEL_PROP ("SYSREG_CTR_EL0_DminLine" ,NUM ,4 ), +MODEL_PROP ("SYSREG_CTR_EL0_ERG" ,NUM ,4 ), +MODEL_PROP ("SYSREG_CTR_EL0_CWG" ,NUM ,4 ), + +MODEL_PROP ("SYSREG_DCZID_EL0_BS" ,NUM ,0x4 ), + +/* pauth */ +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_APA" ,NUM ,3 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR1_EL1_GPA" ,NUM ,1 ), + +/* sve */ +MODEL_PROP ("SYSREG_ID_AA64PFR0_EL1_SVE" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ZFR0_EL1_BF16" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ZFR0_EL1_I8MM" ,NUM ,1 ), +MODEL_PROP ("sve128" ,BOOL , true), + +MODEL_PROP_END , +}; + +static const ArmModelPropValue graviton3_v1_props[] = { +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_AES" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SHA1" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SHA2" ,NUM ,2 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SHA3" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SM3" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_SM4" ,NUM ,1 ), +MODEL_PROP ("SYSREG_ID_AA64ISAR0_EL1_RNDR" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_CTR_EL0_IDC" ,NUM ,1 ), +MODEL_PROP ("SYSREG_CTR_EL0_DIC" ,NUM ,1 ), + +MODEL_PROP ("SYSREG_REVIDR_EL1_VAL" ,NUM ,1 ), + +MODEL_PROP_END , +}; + +static const ArmNamedCpuModel arm_cpu_models[] = { + { + .name ="non-zero-defaults-v1" , + .parent =NULL , + .props = non_zero_defaults_v1_props, + }, + { + .name ="arm-v8_4-a-v1" , + .parent ="non-zero-defaults-v1" , + .props = armv8_4_a_v1_props, + }, + { + .name ="neoverse-v1-v1" , + .parent ="arm-v8_4-a-v1" , + .props = neoverse_v1_v1_props, + }, + { + .name ="graviton3-v1" , + .parent ="neoverse-v1-v1" , + .props = graviton3_v1_props, + }, +}; + +static ARMCPUInfo arm_named_cpu_infos[ARRAY_SIZE (arm_cpu_models)]; +const ArmNamedCpuModel *arm_find_model (const char *name) +{ +size_t i; +for (i =0 ; i <ARRAY_SIZE (arm_cpu_models); i++) { +if (g_str_equal (arm_cpu_models[i].name, name)) { +return &arm_cpu_models[i]; + } + } +return NULL ; +} + +static void arm_apply_model_props (Object *obj,const ArmModelPropValue *props, +Error **errp) +{ +const ArmModelPropValue *pv; +ERRP_GUARD (); + +for (pv = props; pv->name; pv++) { +switch (pv->type) { +case ARM_MODEL_PROP_BOOL : +object_property_set_bool (obj, pv->name, pv->u.b, errp); +break ; +case ARM_MODEL_PROP_NUM : +object_property_set_uint (obj, pv->name, pv->u.num, errp); +break ; +default : +g_assert_not_reached (); + } +if (*errp) { +error_prepend (errp,"property '%s': " , pv->name); +return ; + } + } +} + +static void arm_realize_model_chain (Object *obj,const ArmNamedCpuModel *model, +Error **errp) +{ +const ArmNamedCpuModel *cur, *parent; +const ArmNamedCpuModel *chain[ARRAY_SIZE (arm_cpu_models)]; +size_t depth =0 ; +for (cur = model; cur; ) { +if (depth >=ARRAY_SIZE (chain)) { +error_setg (errp,"model '%s': parent chain too deep " +"(possible cycle)" , model->name); +return ; + } + chain[depth++] = cur; + +if (!cur->parent) { +break ; + } + parent =arm_find_model (cur->parent); +if (!parent) { +error_setg (errp,"model '%s': unknown parent '%s'" , + cur->name, cur->parent); +return ; + } + cur = parent; + } + +while (depth--) { +arm_apply_model_props (obj, chain[depth]->props, errp); +if (*errp) { +return ; + } + } +} + +static void arm_named_cpu_initfn (Object *obj) +{ +ARMCPU *cpu =ARM_CPU (obj); +ARMCPUClass *acc =ARM_CPU_GET_CLASS (obj); +const ArmNamedCpuModel *model =arm_find_model (acc->info->name); +if (!model) { +error_report ("'%s' CPU model entry not found)" , + acc->info->name); +return ; + } + +if (!kvm_enabled ()) { +error_report ("'%s' CPU model requires KVM (-accel kvm)" , + acc->info->name); +return ; + } + +kvm_arm_set_cpu_features_from_host (cpu); +if (!arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) { +return ; + } + +/* 1. Reset ID regs to 0 */ +memset (cpu->isar.idregs,0 ,sizeof (cpu->isar.idregs)); + +/* 2. Add sveNNNN and SYSREG_ properties */ +aarch64_add_sve_properties (obj); +aarch64_add_idregs_properties (obj); + +/* 3. Realize the model chain. */ +arm_realize_model_chain (obj, model, &error_abort); +} + +void arm_register_named_cpu_models (void ) +{ +size_t i; +for (i =0 ; i <ARRAY_SIZE (arm_cpu_models); i++) { + arm_named_cpu_infos[i].name = arm_cpu_models[i].name; + arm_named_cpu_infos[i].initfn = arm_named_cpu_initfn; +arm_cpu_register (&arm_named_cpu_infos[i]); + } +} + +type_init (arm_register_named_cpu_models)target/arm/arm-cpu-models.h new file +35
-0@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* ARM named CPU model definitions - public API. +*/ +#ifndef ARM_CPU_MODELS_H +#define ARM_CPU_MODELS_H + +#include "qapi/error.h" +#include "qom/object.h" + +typedef enum ArmModelPropType { +ARM_MODEL_PROP_BOOL , +ARM_MODEL_PROP_NUM , +}ArmModelPropType ; + +typedef struct ArmModelPropValue { +const char *name; +ArmModelPropType type; +union { +bool b; +uint64_t num; + } u; +}ArmModelPropValue ; + +typedef struct ArmNamedCpuModel { +const char *name; +const char *parent; +const ArmModelPropValue *props; +}ArmNamedCpuModel ; + +void arm_register_named_cpu_models (void ); + +const ArmNamedCpuModel *arm_find_model (const char *name); + +#endif /* ARM_CPU_MODELS_H */ target/arm/meson.build +0
-0@@ -10,7 +10,7 @@ arm_user_ss.add(files('gdbstub.c'))arm_ss.add(when: '
TARGET_AARCH64',if_true: files(
'cpu64.c',target/arm/meson.build +1
-1- 'gdbstub64.c' + 'gdbstub64.c',))
arm_common_ss.add(files(
target/arm/meson.build +0
-0@@ -21,7 +21,10 @@ arm_common_system_ss.add(files( 'arm-qmp-cmds.c',target/arm/meson.build arm_common_system_ss.add(files( · line 30
Quoted 10 lines
target/arm/meson.build +4
-1'cpu-idregs.c', )) -arm_system_ss.add(when: 'CONFIG_KVM', if_true: files('hyp_gdbstub.c', 'kvm.c')) +arm_system_ss.add(when: 'TARGET_AARCH64', if_true: files('arm-cpu-models.c')) +arm_system_ss.add(when: 'CONFIG_KVM', + if_true: files('hyp_gdbstub.c', + 'kvm.c')) arm_system_ss.add(when: 'CONFIG_HVF', if_true: files('hyp_gdbstub.c')) arm_user_ss.add(files('cpu.c'))Thanks
Eric
Thanks
Eric
RFC PATCH v3 10/19 target/arm: Add Nvidia Grace named model
In reply to Khushit ShahAdd Nvidia Grace named model alongside its hierarchy (neoverse-v2, armv9-a)
Field values were derived from the ID register view that KVM exposes to QEMU with -cpu host on an Nvidia Grace system.
--- hw/arm/virt.c | 3 + target/arm/arm-cpu-models.c | 154 +++++++++++++++++++++++++++++++++++- 2 files changed, 156 insertions(+), 1 deletion(-)
hw/arm/virt.c +3 -0
@@ -3816,6 +3816,9 @@ static GPtrArray *virt_get_valid_cpu_types(const MachineState *ms)g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("arm-v8_4-a-v1" )));g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("neoverse-v1-v1" )));g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("graviton3-v1" ))); +g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("arm-v9_0-a-v1" ))); +g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("neoverse-v2-v1" ))); +g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("grace-v1" ))); }g_ptr_array_add (vct,g_strdup (ARM_CPU_TYPE_NAME ("max" )));
target/arm/arm-cpu-models.c +153 -1
172 lines not on this page · raw message
Signature · 1 line
2.52.0
RFC PATCH v3 11/19 target/arm: fix sve and pauth finalize for named cpu models
In reply to Khushit ShahNamed models provide authoritative ID-register values, so don't derive SVE vector lengths or pauth fields from the host; require explicit SVE lengths and leave the model's pauth fields intact.
--- target/arm/cpu64.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
target/arm/cpu64.c +29 -0
@@ -38,6 +38,7 @@#include "internals.h" #include "cpu-features.h" #include "cpu-idregs.h" +#include "arm-cpu-models.h" #include "trace.h" /* convert between <register>_IDX and SYS_<register> */
@@ -134,6 +135,20 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp)return ; } +/* +* If SVE is enabled but no vector lengths are specified, we must not +* default to the host's supported lengths for named CPU models, as +* this breaks live migration. +*/ + { +ARMCPUClass *acc =ARM_CPU_GET_CLASS (cpu); +if (acc->info &&arm_find_model (acc->info->name)) { +error_setg (errp, +"Named CPU models with SVE must set vector lengths" ); +return ; + } + } +if (kvm_enabled ()) {/* Disabling a supported length disables all larger lengths. */ tmp = vq_init & vq_supported;
@@ -556,6 +571,20 @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp)ARMISARegisters *isar = &cpu->isar;uint64_t isar1, isar2; +/* +* For named CPU models the model props write the authoritative +* APA/API/APA3/GPA/GPI/GPA3 values directly into cpu->isar, so do not +* override them here. Since other code relies on cpu->prop_pauth, +* mirror the resulting pauth state into prop_pauth. +*/ + { +ARMCPUClass *acc =ARM_CPU_GET_CLASS (cpu); +if (acc->info &&arm_find_model (acc->info->name)) { + cpu->prop_pauth =cpu_isar_feature (aa64_pauth, cpu); +return ; + } + } +/* * These properties enable or disable Pauth as a whole, or change * the pauth algorithm, but do not change the set of features that
Signature · 1 line
2.52.0
RFC PATCH v3 12/19 target/arm: Introduce stub files required for qmp support
In reply to Khushit ShahAdd arm-cpu-models-stub.c, which will be required to add qmp support.
--- target/arm/arm-cpu-models-stub.c | 13 +++++++++++++ target/arm/meson.build | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 target/arm/arm-cpu-models-stub.c
target/arm/arm-cpu-models-stub.c new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* ARM named CPU model definitions - stub implementation. +*/ +#include "qemu/osdep.h" +#include "cpu.h" +#include "arm-cpu-models.h" + + +const ArmNamedCpuModel *arm_find_model (const char *name) +{ +return NULL ; +}
target/arm/meson.build +2 -1
@@ -21,7 +21,8 @@ arm_common_system_ss.add(files( 'arm-qmp-cmds.c', 'cpu-idregs.c', )) -arm_system_ss.add(when: 'TARGET_AARCH64', if_true: files('arm-cpu-models.c')) +arm_system_ss.add(when: 'TARGET_AARCH64', if_true: files('arm-cpu-models.c'), + if_false: files('arm-cpu-models-stub.c')) arm_system_ss.add(when: 'CONFIG_KVM', if_true: files('hyp_gdbstub.c', 'kvm.c'))
Signature · 1 line
2.52.0
RFC PATCH v3 13/19 target/arm/qmp: add named models and properties to cpu-model-expansion
In reply to Khushit ShahAllow expansion of the new named CPU models.
--- target/arm/arm-qmp-cmds.c | 9 +++++++++ 1 file changed, 9 insertions(+)
target/arm/arm-qmp-cmds.c +9 -0
@@ -33,6 +33,7 @@#include "qobject/qdict.h" #include "qom/qom-qobject.h" #include "cpu.h" +#include "arm-cpu-models.h" static GICCapability *gic_cap_new (int version) {
@@ -92,6 +93,7 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,ObjectClass *oc;Object *obj;const char *name; +bool named_model = (arm_find_model (model->name) !=NULL );int i;if (type !=CPU_MODEL_EXPANSION_TYPE_FULL ) {
@@ -104,6 +106,11 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,return NULL ; } +if (!kvm_enabled () && named_model) { +error_setg (errp,"The CPU type '%s' requires KVM" , model->name); +return NULL ; + } + oc =cpu_class_by_name (TYPE_ARM_CPU , model->name);if (!oc) { error_setg(errp, "The CPU type '%s' is not a recognized ARM CPU type",
@@ -117,6 +124,8 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,if (!strcmp (model->name,"host" ) || !strcmp (model->name,"max" )) {/* These are kvmarm's recommended cpu types */ supported = true; + }else if (named_model) { + supported = true; }else if (current_machine->cpu_type) {const char *cpu_type = current_machine->cpu_type;int len =strlen (cpu_type) -strlen (ARM_CPU_TYPE_SUFFIX );
Signature · 1 line
2.52.0
RFC PATCH v3 14/19 target/arm/kvm: compute supported values for ID register fields
In reply to Khushit ShahAdd arm_field_get_supported_values() which, for a given ID register field, builds the set of values KVM allows it to take on the live host.
Non-writable fields are pinned to the host value. Writable fields follow their per field constraints. This function likely needs change when KVM starts exposing a new writable field that is not lower-safe, hence, the special handling of TGranX_2/SpecSEI/L1Ip/MIDR/REVIDR/AIDR.
Cross-field constraints are not modelled; for example ID_AA64ZFR0_EL1 is gated by SVE. Reproducing every inter-field dependency in QEMU would only duplicate KVM's logic and drift out of sync with it.
--- target/arm/kvm.c | 99 ++++++++++++++++++++++++++++++++++++++++++++ target/arm/kvm_arm.h | 26 ++++++++++++ 2 files changed, 125 insertions(+)
target/arm/kvm.c +99 -0
@@ -1262,6 +1262,105 @@ bool kvm_arm_cpu_post_load(ARMCPU *cpu)return true; } +static bool arm_field_is_signed (const ARM64SysRegField *field) +{ +return field_matches (field,ID_AA64MMFR0_EL1_IDX ,"TGran4" ) || +field_matches (field,ID_AA64MMFR0_EL1_IDX ,"TGran64" ) || +field_matches (field,ID_MMFR0_EL1_IDX ,"InnerShr" ) || +field_matches (field,ID_MMFR0_EL1_IDX ,"OuterShr" ) || +field_matches (field,ID_AA64DFR0_EL1_IDX ,"DoubleLock" ) || +field_matches (field,ID_AA64DFR0_EL1_IDX ,"PMUVer" ) || +field_matches (field,ID_DFR0_EL1_IDX ,"PerfMon" ) || +field_matches (field,ID_AA64PFR1_EL1_IDX ,"MTE_frac" ) || +field_matches (field,ID_AA64MMFR4_EL1_IDX ,"E2H0" ) || +field_matches (field,ID_DFR1_EL1_IDX ,"MTPMU" ) || +field_matches (field,ID_AA64PFR0_EL1_IDX ,"FP" ) || +field_matches (field,ID_AA64PFR0_EL1_IDX ,"AdvSIMD" ); +} + +static void ranges_add (GArray *ranges,uint64_t min,uint64_t max) +{ +ArmFieldRange r = { .min = min, .max = max }; +g_array_append_val (ranges, r); +} + +void arm_field_get_supported_values (const ARM64SysRegField *field, +const ARMISARegisters *host_isar, +ArmFieldValueSet **value_set) +{ +bool is_signed =arm_field_is_signed (field); +uint64_t host =extract64 (host_isar->idregs[field->index], + field->shift, field->length); +GArray *ranges =g_array_new (false, false,sizeof (ArmFieldRange)); + +/* A non-writable field can only ever hold the host value. */ +if (!arm_field_is_writable (field)) { +ranges_add (ranges, host, host); + goto done; + } + +if (field_matches (field,ID_AA64MMFR0_EL1_IDX ,"TGran4_2" ) || +field_matches (field,ID_AA64MMFR0_EL1_IDX ,"TGran16_2" ) || +field_matches (field,ID_AA64MMFR0_EL1_IDX ,"TGran64_2" )) { +/* Either support the host value or the "off" value */ +ranges_add (ranges, host, host); +if (host !=1 ) {/* 1 = "off" */ +ranges_add (ranges,1 ,1 ); + } + }else if (field_matches (field,CTR_EL0_IDX ,"L1Ip" )) { +/* Only safe to downgrade to VIPT, other values are reserved. */ +ranges_add (ranges, host, host); +if (host !=2 ) {/* 2 = "VIPT" */ +ranges_add (ranges,2 ,2 ); + } + }else if (field_matches (field,ID_AA64MMFR1_EL1_IDX ,"SpecSEI" ) || +field_matches (field,ID_MMFR4_EL1_IDX ,"SpecSEI" )) { +/* It is safe to upgrade SpecSEI to 1, other values are reserved. */ +ranges_add (ranges, host, host); +if (host !=1 ) { +ranges_add (ranges,1 ,1 ); + } + }else if (field->index ==MIDR_EL1_IDX || + field->index ==REVIDR_EL1_IDX || + field->index ==AIDR_EL1_IDX ) { +/* +* No restriction on value that can be set for implementation ID +* registers fields. +*/ +uint64_t max =0 ; +if (field->length ==64 ) { + max = ~0ULL ; + }else { + max = (1ULL << field->length) -1 ; + } +ranges_add (ranges,0 , max); + }else { +/* +* After handling the special cases, other writable fields are +* either lower-safe or signed lower-safe. +*/ +if (field->arch_vals_count) { +for (uint32_t i =0 ; i < field->arch_vals_count; i++) { +uint64_t av = field->arch_vals[i].value; +int64_t v = is_signed ? +sextract64 (av,0 , field->length) : (int64_t )av; +int64_t hv = is_signed ? +sextract64 (host,0 , field->length) : (int64_t )host; +if (v <= hv) { +ranges_add (ranges, av, av); + } + } + }else { +g_assert (!is_signed);/* No signed field with no arch vals */ +ranges_add (ranges,0 , host); + } + } +done: + *value_set =g_new0 (ArmFieldValueSet,1 ); + (*value_set)->n_ranges = ranges->len; + (*value_set)->ranges = (ArmFieldRange *)g_array_free (ranges, false); +} +static bool arm_field_skip_writeback_always (const ARM64SysRegField *field) {/*
target/arm/kvm_arm.h +26 -0
@@ -143,6 +143,32 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu);void kvm_arm_add_vcpu_properties (ARMCPU *cpu);typedef struct ARM64SysReg ARM64SysReg ; +typedef struct ARM64SysRegField ARM64SysRegField ; +typedef struct ARMISARegisters ARMISARegisters ; + +typedef struct ArmFieldRange { +uint64_t min; +uint64_t max; +}ArmFieldRange ; + +typedef struct ArmFieldValueSet { +ArmFieldRange *ranges; +size_t n_ranges; +}ArmFieldValueSet ; + +/** +* arm_field_get_supported_values: +* @field: The field to get the supported values for +* @host_isar: The host ISAR registers +* @value_set: The set of supported values for the @field +* +* Will be allocated and filled in with the supported values for the @field +* based on the host_isar and whether the field is writable or not. +* The caller must free the value_set. +*/ +void arm_field_get_supported_values (const ARM64SysRegField *field, +const ARMISARegisters *host_isar, +ArmFieldValueSet **value_set);/** * kvm_arm_steal_time_finalize:
Signature · 1 line
2.52.0
Re: [RFC PATCH v3 14/19] target/arm/kvm: compute supported values for ID register fields
Hi Khushit,
Quoted 7 lines · Khushit Shah
Add
arm_field_get_supported_values()which, for a given ID register field, builds the set of values KVM allows it to take on the live host.Non-writable fields are pinned to the host value. Writable fields follow their per field constraints. This function likely needs change when KVM starts exposing a new writable field that is not lower-safe, hence, the special handling of TGranX_2/SpecSEI/L1Ip/MIDR/REVIDR/AIDR.
so this looks quite risky.
Quoted 4 lines
Cross-field constraints are not modelled; for example
ID_AA64ZFR0_EL1is gated by SVE. Reproducing every inter-field dependency in QEMU would only duplicate KVM's logic and drift out of sync with it.
Isn't qmp_query_cpu_model_expansion sufficient? In general upper layers will try to apply raw named models. If ajustements are needed between source and destination, we know field candidate values (either the source or dest one) and this latter can be directly tried using qmp_query_cpu_model_expansion write. On top of that qmp_query_cpu_model_expansion can be directly checked against a scratch vcpu reusing the logic implemented at kernel level.
Quoted 19 lines
Signed-off-by Khushit Shah <[email protected]>--- target/arm/kvm.c | 99 ++++++++++++++++++++++++++++++++++++++++++++ target/arm/kvm_arm.h | 26 ++++++++++++ 2 files changed, 125 insertions(+)target/arm/kvm.c +4
-0@@ -1262,6 +1262,105 @@ bool kvm_arm_cpu_post_load(ARMCPU *cpu)return true; } +static bool arm_field_is_signed (const ARM64SysRegField *field) +{ +return field_matches (field,ID_AA64MMFR0_EL1_IDX ,"TGran4" ) || + field_matches(field, ID_AA64MMFR0_EL1_IDX, "TGran64") ||
target/arm/kvm.c bool kvm_arm_cpu_post_load(ARMCPU *cpu) · line 1278
Quoted 10 lines
target/arm/kvm.c +10
-0+field_matches (field,ID_MMFR0_EL1_IDX ,"InnerShr" ) || +field_matches (field,ID_MMFR0_EL1_IDX ,"OuterShr" ) || +field_matches (field,ID_AA64DFR0_EL1_IDX ,"DoubleLock" ) || +field_matches (field,ID_AA64DFR0_EL1_IDX ,"PMUVer" ) || +field_matches (field,ID_DFR0_EL1_IDX ,"PerfMon" ) || +field_matches (field,ID_AA64PFR1_EL1_IDX ,"MTE_frac" ) || +field_matches (field,ID_AA64MMFR4_EL1_IDX ,"E2H0" ) || +field_matches (field,ID_DFR1_EL1_IDX ,"MTPMU" ) || +field_matches (field,ID_AA64PFR0_EL1_IDX ,"FP" ) || +field_matches (field,ID_AA64PFR0_EL1_IDX ,"AdvSIMD" );
Can't we extract this from Register.json instead?
Quoted 11 lines
target/arm/kvm.c +11
-0+} + +static void ranges_add (GArray *ranges,uint64_t min,uint64_t max) +{ +ArmFieldRange r = { .min = min, .max = max }; +g_array_append_val (ranges, r); +} + +void arm_field_get_supported_values (const ARM64SysRegField *field, +const ARMISARegisters *host_isar, +ArmFieldValueSet **value_set)
target/arm/kvm.c bool kvm_arm_cpu_post_load(ARMCPU *cpu) · line 1299
Quoted 10 lines
target/arm/kvm.c +10
-0+{ +bool is_signed =arm_field_is_signed (field); +uint64_t host =extract64 (host_isar->idregs[field->index], + field->shift, field->length); +GArray *ranges =g_array_new (false, false,sizeof (ArmFieldRange)); + +/* A non-writable field can only ever hold the host value. */ +if (!arm_field_is_writable (field)) { +ranges_add (ranges, host, host); + goto done;
you already get this info from qmp_query_cpu_model_expansion
Quoted 94 lines
target/arm/kvm.c +64
-0+ } + +if (field_matches (field,ID_AA64MMFR0_EL1_IDX ,"TGran4_2" ) || +field_matches (field,ID_AA64MMFR0_EL1_IDX ,"TGran16_2" ) || +field_matches (field,ID_AA64MMFR0_EL1_IDX ,"TGran64_2" )) { +/* Either support the host value or the "off" value */ +ranges_add (ranges, host, host); +if (host !=1 ) {/* 1 = "off" */ +ranges_add (ranges,1 ,1 ); + } + }else if (field_matches (field,CTR_EL0_IDX ,"L1Ip" )) { +/* Only safe to downgrade to VIPT, other values are reserved. */ +ranges_add (ranges, host, host); +if (host !=2 ) {/* 2 = "VIPT" */ +ranges_add (ranges,2 ,2 ); + } + }else if (field_matches (field,ID_AA64MMFR1_EL1_IDX ,"SpecSEI" ) || +field_matches (field,ID_MMFR4_EL1_IDX ,"SpecSEI" )) { +/* It is safe to upgrade SpecSEI to 1, other values are reserved. */ +ranges_add (ranges, host, host); +if (host !=1 ) { +ranges_add (ranges,1 ,1 ); + } + }else if (field->index ==MIDR_EL1_IDX || + field->index ==REVIDR_EL1_IDX || + field->index ==AIDR_EL1_IDX ) { +/* +* No restriction on value that can be set for implementation ID +* registers fields. +*/ +uint64_t max =0 ; +if (field->length ==64 ) { + max = ~0ULL ; + }else { + max = (1ULL << field->length) -1 ; + } +ranges_add (ranges,0 , max); + }else { +/* +* After handling the special cases, other writable fields are +* either lower-safe or signed lower-safe. +*/ +if (field->arch_vals_count) { +for (uint32_t i =0 ; i < field->arch_vals_count; i++) { +uint64_t av = field->arch_vals[i].value; +int64_t v = is_signed ? +sextract64 (av,0 , field->length) : (int64_t )av; +int64_t hv = is_signed ? +sextract64 (host,0 , field->length) : (int64_t )host; +if (v <= hv) { +ranges_add (ranges, av, av); + } + } + }else { +g_assert (!is_signed);/* No signed field with no arch vals */ +ranges_add (ranges,0 , host); + } + } +done: + *value_set =g_new0 (ArmFieldValueSet,1 ); + (*value_set)->n_ranges = ranges->len; + (*value_set)->ranges = (ArmFieldRange *)g_array_free (ranges, false); +} +static bool arm_field_skip_writeback_always (const ARM64SysRegField *field) {/* target/arm/kvm_arm.h +19
-0@@ -143,6 +143,32 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu);void kvm_arm_add_vcpu_properties (ARMCPU *cpu);typedef struct ARM64SysReg ARM64SysReg ; +typedef struct ARM64SysRegField ARM64SysRegField ; +typedef struct ARMISARegisters ARMISARegisters ; + +typedef struct ArmFieldRange { +uint64_t min; +uint64_t max; +}ArmFieldRange ; + +typedef struct ArmFieldValueSet { +ArmFieldRange *ranges; +size_t n_ranges; +}ArmFieldValueSet ; + +/** +* arm_field_get_supported_values: +* @field: The field to get the supported values for +* @host_isar: The host ISAR registers +* @value_set: The set of supported values for the @field +*
target/arm/kvm_arm.h void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu); · line 174
Quoted 10 lines
target/arm/kvm_arm.h +7
-0+* Will be allocated and filled in with the supported values for the @field +* based on the host_isar and whether the field is writable or not. +* The caller must free the value_set. +*/ +void arm_field_get_supported_values (const ARM64SysRegField *field, +const ARMISARegisters *host_isar, +ArmFieldValueSet **value_set);/** * kvm_arm_steal_time_finalize:
Thanks
Eric
Re: [RFC PATCH v3 14/19] target/arm/kvm: compute supported values for ID register fields
Quoted 12 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Hi Khushit,
On 7/16/26 11:38 PM, Khushit Shah wrote:
Quoted 8 lines
Quoted 7 lines
Add
arm_field_get_supported_values()which, for a given ID register field, builds the set of values KVM allows it to take on the live host.Non-writable fields are pinned to the host value. Writable fields follow their per field constraints. This function likely needs change when KVM starts exposing a new writable field that is not lower-safe, hence, the special handling of TGranX_2/SpecSEI/L1Ip/MIDR/REVIDR/AIDR.
so this looks quite risky.
I agree.
What are your thoughts on having a authoritative list in QEMU of all writable fields? No matter what KVM exposes as writable, actual fields we allow to be writable will be intersection of KVM writable + QEMU writable. When The QEMU list is updated we make sure things like this function is updated.
This get’s rid of cases where we silently support writing to a field. It is similar to x86, QEMU only supports writing to specific CPUID leafs (by the defined Properties) and not just any CPUID leafs.
Quoted 5 lines
Quoted 4 lines
Cross-field constraints are not modelled; for example
ID_AA64ZFR0_EL1is gated by SVE. Reproducing every inter-field dependency in QEMU would only duplicate KVM's logic and drift out of sync with it.
Quoted 7 lines
Isn't
qmp_query_cpu_model_expansionsufficient? In general upper layers will try to apply raw named models. If ajustements are needed between source and destination, we know field candidate values (either the source or dest one) and this latter can be directly tried usingqmp_query_cpu_model_expansionwrite. On top of thatqmp_query_cpu_model_expansioncan be directly checked against a scratch vcpu reusing the logic implemented at kernel level.
I am not sure if it is acceptable for query_cpu_model_expansion should fail if model is not realisable. On at least x86 it does not. It just returns the state which QEMU would request KVM for the given configurations.
Ref:
https://github.com/qemu/qemu/blob/3e3ccab106f879b1512f8e0d51a827dd4de30e22/target/i386/cpu.c#L9689
cpu-definitions is maybe a better candidate for algo you are describing, but it will not take the user overrides into considerations and only say if a base model is usable or not
Quoted 14 lines
Quoted 14 lines
Signed-off-by Khushit Shah <[email protected]>---
target/arm/kvm.c| 99 ++++++++++++++++++++++++++++++++++++++++++++target/arm/kvm_arm.h| 26 ++++++++++++2 files changed, 125 insertions(+)target/arm/kvm.c +0
-0@@ -1262,6 +1262,105 @@ bool kvm_arm_cpu_post_load(ARMCPU *cpu)return true; }
Quoted 15 lines
Quoted 4 lines
target/arm/kvm.c +4
-0+static bool arm_field_is_signed (const ARM64SysRegField *field) +{ +return field_matches (field,ID_AA64MMFR0_EL1_IDX ,"TGran4" ) || + field_matches(field, ID_AA64MMFR0_EL1_IDX, "TGran64") ||target/arm/kvm.c bool kvm_arm_cpu_post_load(ARMCPU *cpu) · line 1278
Quoted 10 lines
target/arm/kvm.c +10
-0+field_matches (field,ID_MMFR0_EL1_IDX ,"InnerShr" ) || +field_matches (field,ID_MMFR0_EL1_IDX ,"OuterShr" ) || +field_matches (field,ID_AA64DFR0_EL1_IDX ,"DoubleLock" ) || +field_matches (field,ID_AA64DFR0_EL1_IDX ,"PMUVer" ) || +field_matches (field,ID_DFR0_EL1_IDX ,"PerfMon" ) || +field_matches (field,ID_AA64PFR1_EL1_IDX ,"MTE_frac" ) || +field_matches (field,ID_AA64MMFR4_EL1_IDX ,"E2H0" ) || +field_matches (field,ID_DFR1_EL1_IDX ,"MTPMU" ) || +field_matches (field,ID_AA64PFR0_EL1_IDX ,"FP" ) || +field_matches (field,ID_AA64PFR0_EL1_IDX ,"AdvSIMD" );Can't we extract this from Register.json instead?
AFAIK, There is not signedness data in Register.json
Quoted 14 lines
Quoted 14 lines
target/arm/kvm.c +14
-0+} + +static void ranges_add (GArray *ranges,uint64_t min,uint64_t max) +{ +ArmFieldRange r = { .min = min, .max = max }; +g_array_append_val (ranges, r); +} + +void arm_field_get_supported_values (const ARM64SysRegField *field, +const ARMISARegisters *host_isar, +ArmFieldValueSet **value_set) +{ +bool is_signed =arm_field_is_signed (field); + uint64_t host = extract64(host_isar->idregs[field->index],
Quoted 8 lines
target/arm/kvm.c bool kvm_arm_cpu_post_load(ARMCPU *cpu) · line 1299
Quoted 7 lines
target/arm/kvm.c +7
-0+ field->shift, field->length); +GArray *ranges =g_array_new (false, false,sizeof (ArmFieldRange)); + +/* A non-writable field can only ever hold the host value. */ +if (!arm_field_is_writable (field)) { +ranges_add (ranges, host, host); + goto done;you already get this info from
qmp_query_cpu_model_expansion
Can you please elaborate how? I thought the current qmp_query_cpu_model_expansion (Your v6) only returns the writable field.
(I have not yet looked at v7)
Quoted 107 lines
Quoted 94 lines
target/arm/kvm.c +64
-0+ } + +if (field_matches (field,ID_AA64MMFR0_EL1_IDX ,"TGran4_2" ) || +field_matches (field,ID_AA64MMFR0_EL1_IDX ,"TGran16_2" ) || +field_matches (field,ID_AA64MMFR0_EL1_IDX ,"TGran64_2" )) { +/* Either support the host value or the "off" value */ +ranges_add (ranges, host, host); +if (host !=1 ) {/* 1 = "off" */ +ranges_add (ranges,1 ,1 ); + } + }else if (field_matches (field,CTR_EL0_IDX ,"L1Ip" )) { +/* Only safe to downgrade to VIPT, other values are reserved. */ +ranges_add (ranges, host, host); +if (host !=2 ) {/* 2 = "VIPT" */ +ranges_add (ranges,2 ,2 ); + } + }else if (field_matches (field,ID_AA64MMFR1_EL1_IDX ,"SpecSEI" ) || +field_matches (field,ID_MMFR4_EL1_IDX ,"SpecSEI" )) { +/* It is safe to upgrade SpecSEI to 1, other values are reserved. */ +ranges_add (ranges, host, host); +if (host !=1 ) { +ranges_add (ranges,1 ,1 ); + } + }else if (field->index ==MIDR_EL1_IDX || + field->index ==REVIDR_EL1_IDX || + field->index ==AIDR_EL1_IDX ) { +/* +* No restriction on value that can be set for implementation ID +* registers fields. +*/ +uint64_t max =0 ; +if (field->length ==64 ) { + max = ~0ULL ; + }else { + max = (1ULL << field->length) -1 ; + } +ranges_add (ranges,0 , max); + }else { +/* +* After handling the special cases, other writable fields are +* either lower-safe or signed lower-safe. +*/ +if (field->arch_vals_count) { +for (uint32_t i =0 ; i < field->arch_vals_count; i++) { +uint64_t av = field->arch_vals[i].value; +int64_t v = is_signed ? +sextract64 (av,0 , field->length) : (int64_t )av; +int64_t hv = is_signed ? +sextract64 (host,0 , field->length) : (int64_t )host; +if (v <= hv) { +ranges_add (ranges, av, av); + } + } + }else { +g_assert (!is_signed);/* No signed field with no arch vals */ +ranges_add (ranges,0 , host); + } + } +done: + *value_set =g_new0 (ArmFieldValueSet,1 ); + (*value_set)->n_ranges = ranges->len; + (*value_set)->ranges = (ArmFieldRange *)g_array_free (ranges, false); +} +static bool arm_field_skip_writeback_always (const ARM64SysRegField *field) {/* target/arm/kvm_arm.h +19
-0@@ -143,6 +143,32 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu);void kvm_arm_add_vcpu_properties (ARMCPU *cpu);typedef struct ARM64SysReg ARM64SysReg ; +typedef struct ARM64SysRegField ARM64SysRegField ; +typedef struct ARMISARegisters ARMISARegisters ; + +typedef struct ArmFieldRange { +uint64_t min; +uint64_t max; +}ArmFieldRange ; + +typedef struct ArmFieldValueSet { +ArmFieldRange *ranges; +size_t n_ranges; +}ArmFieldValueSet ; + +/** +* arm_field_get_supported_values: +* @field: The field to get the supported values for +* @host_isar: The host ISAR registers +* @value_set: The set of supported values for the @field +* target/arm/kvm_arm.h void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu); · line 174
Quoted 10 lines
target/arm/kvm_arm.h +7
-0+* Will be allocated and filled in with the supported values for the @field +* based on the host_isar and whether the field is writable or not. +* The caller must free the value_set. +*/ +void arm_field_get_supported_values (const ARM64SysRegField *field, +const ARMISARegisters *host_isar, +ArmFieldValueSet **value_set);/** * kvm_arm_steal_time_finalize: Thanks
Eric
Re: [RFC PATCH v3 14/19] target/arm/kvm: compute supported values for ID register fields
Quoted 41 lines · Khushit Shah
Quoted 11 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Hi Khushit,
On 7/16/26 11:38 PM, Khushit Shah wrote:
Quoted 8 lines
Quoted 7 lines
Add
arm_field_get_supported_values()which, for a given ID register field, builds the set of values KVM allows it to take on the live host.Non-writable fields are pinned to the host value. Writable fields follow their per field constraints. This function likely needs change when KVM starts exposing a new writable field that is not lower-safe, hence, the special handling of TGranX_2/SpecSEI/L1Ip/MIDR/REVIDR/AIDR.
so this looks quite risky.
I agree.
What are your thoughts on having a authoritative list in QEMU of all writable fields? No matter what KVM exposes as writable, actual fields we allow to be writable will be intersection of KVM writable + QEMU writable. When The QEMU list is updated we make sure things like this function is updated.
This get’s rid of cases where we silently support writing to a field. It is similar to x86, QEMU only supports writing to specific CPUID leafs (by the defined Properties) and not just any CPUID leafs.
Quoted 10 lines
Quoted 3 lines
Cross-field constraints are not modelled; for example
ID_AA64ZFR0_EL1is gated by SVE. Reproducing every inter-field dependency in QEMU would only duplicate KVM's logic and drift out of sync with it.Isn't
qmp_query_cpu_model_expansionsufficient? In general upper layers will try to apply raw named models. If ajustements are needed between source and destination, we know field candidate values (either the source or dest one) and this latter can be directly tried usingqmp_query_cpu_model_expansionwrite. On top of thatqmp_query_cpu_model_expansioncan be directly checked against a scratch vcpu reusing the logic implemented at kernel level.
Quoted 6 lines
I am not sure if it is acceptable for
query_cpu_model_expansionshould fail if model is not realisable. On at least x86 it does not. It just returns the state which QEMU would request KVM for the given configurations.Ref:
https://github.com/qemu/qemu/blob/3e3ccab106f879b1512f8e0d51a827dd4de30e22/target/i386/cpu.c#L9689
I need to further study that. I will come back to you.
Currently with v7 you get:
(QEMU) query-cpu-model-expansion type=full model={"name":"host","props":{"SYSREG_ID_AA64MMFR1_EL1_AFP":0x1}} {"error": {"class": "GenericError", "desc": "failed to apply new value 0x1 for field AFP (previous is 0x0): Invalid argument"}}
This can be implemented elsewhere though
Eric
Quoted 171 lines
cpu-definitions is maybe a better candidate for algo you are describing, but it will not take the user overrides into considerations and only say if a base model is usable or not
Quoted 14 lines
Quoted 14 lines
Signed-off-by Khushit Shah <[email protected]>---
target/arm/kvm.c| 99 ++++++++++++++++++++++++++++++++++++++++++++target/arm/kvm_arm.h| 26 ++++++++++++2 files changed, 125 insertions(+)target/arm/kvm.c +0
-0@@ -1262,6 +1262,105 @@ bool kvm_arm_cpu_post_load(ARMCPU *cpu)return true; }Quoted 15 lines
Quoted 4 lines
target/arm/kvm.c +4
-0+static bool arm_field_is_signed (const ARM64SysRegField *field) +{ +return field_matches (field,ID_AA64MMFR0_EL1_IDX ,"TGran4" ) || + field_matches(field, ID_AA64MMFR0_EL1_IDX, "TGran64") ||target/arm/kvm.c bool kvm_arm_cpu_post_load(ARMCPU *cpu) · line 1278
Quoted 10 lines
target/arm/kvm.c +10
-0+field_matches (field,ID_MMFR0_EL1_IDX ,"InnerShr" ) || +field_matches (field,ID_MMFR0_EL1_IDX ,"OuterShr" ) || +field_matches (field,ID_AA64DFR0_EL1_IDX ,"DoubleLock" ) || +field_matches (field,ID_AA64DFR0_EL1_IDX ,"PMUVer" ) || +field_matches (field,ID_DFR0_EL1_IDX ,"PerfMon" ) || +field_matches (field,ID_AA64PFR1_EL1_IDX ,"MTE_frac" ) || +field_matches (field,ID_AA64MMFR4_EL1_IDX ,"E2H0" ) || +field_matches (field,ID_DFR1_EL1_IDX ,"MTPMU" ) || +field_matches (field,ID_AA64PFR0_EL1_IDX ,"FP" ) || +field_matches (field,ID_AA64PFR0_EL1_IDX ,"AdvSIMD" );Can't we extract this from Register.json instead?
AFAIK, There is not signedness data in Register.json
Quoted 14 lines
Quoted 14 lines
target/arm/kvm.c +14
-0+} + +static void ranges_add (GArray *ranges,uint64_t min,uint64_t max) +{ +ArmFieldRange r = { .min = min, .max = max }; +g_array_append_val (ranges, r); +} + +void arm_field_get_supported_values (const ARM64SysRegField *field, +const ARMISARegisters *host_isar, +ArmFieldValueSet **value_set) +{ +bool is_signed =arm_field_is_signed (field); + uint64_t host = extract64(host_isar->idregs[field->index],Quoted 8 lines
target/arm/kvm.c bool kvm_arm_cpu_post_load(ARMCPU *cpu) · line 1299
Quoted 7 lines
target/arm/kvm.c +7
-0+ field->shift, field->length); +GArray *ranges =g_array_new (false, false,sizeof (ArmFieldRange)); + +/* A non-writable field can only ever hold the host value. */ +if (!arm_field_is_writable (field)) { +ranges_add (ranges, host, host); + goto done;you already get this info from
qmp_query_cpu_model_expansionCan you please elaborate how? I thought the current
qmp_query_cpu_model_expansion(Your v6) only returns the writable field.
(I have not yet looked at v7)Quoted 107 lines
Quoted 94 lines
target/arm/kvm.c +64
-0+ } + +if (field_matches (field,ID_AA64MMFR0_EL1_IDX ,"TGran4_2" ) || +field_matches (field,ID_AA64MMFR0_EL1_IDX ,"TGran16_2" ) || +field_matches (field,ID_AA64MMFR0_EL1_IDX ,"TGran64_2" )) { +/* Either support the host value or the "off" value */ +ranges_add (ranges, host, host); +if (host !=1 ) {/* 1 = "off" */ +ranges_add (ranges,1 ,1 ); + } + }else if (field_matches (field,CTR_EL0_IDX ,"L1Ip" )) { +/* Only safe to downgrade to VIPT, other values are reserved. */ +ranges_add (ranges, host, host); +if (host !=2 ) {/* 2 = "VIPT" */ +ranges_add (ranges,2 ,2 ); + } + }else if (field_matches (field,ID_AA64MMFR1_EL1_IDX ,"SpecSEI" ) || +field_matches (field,ID_MMFR4_EL1_IDX ,"SpecSEI" )) { +/* It is safe to upgrade SpecSEI to 1, other values are reserved. */ +ranges_add (ranges, host, host); +if (host !=1 ) { +ranges_add (ranges,1 ,1 ); + } + }else if (field->index ==MIDR_EL1_IDX || + field->index ==REVIDR_EL1_IDX || + field->index ==AIDR_EL1_IDX ) { +/* +* No restriction on value that can be set for implementation ID +* registers fields. +*/ +uint64_t max =0 ; +if (field->length ==64 ) { + max = ~0ULL ; + }else { + max = (1ULL << field->length) -1 ; + } +ranges_add (ranges,0 , max); + }else { +/* +* After handling the special cases, other writable fields are +* either lower-safe or signed lower-safe. +*/ +if (field->arch_vals_count) { +for (uint32_t i =0 ; i < field->arch_vals_count; i++) { +uint64_t av = field->arch_vals[i].value; +int64_t v = is_signed ? +sextract64 (av,0 , field->length) : (int64_t )av; +int64_t hv = is_signed ? +sextract64 (host,0 , field->length) : (int64_t )host; +if (v <= hv) { +ranges_add (ranges, av, av); + } + } + }else { +g_assert (!is_signed);/* No signed field with no arch vals */ +ranges_add (ranges,0 , host); + } + } +done: + *value_set =g_new0 (ArmFieldValueSet,1 ); + (*value_set)->n_ranges = ranges->len; + (*value_set)->ranges = (ArmFieldRange *)g_array_free (ranges, false); +} +static bool arm_field_skip_writeback_always (const ARM64SysRegField *field) {/* target/arm/kvm_arm.h +19
-0@@ -143,6 +143,32 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu);void kvm_arm_add_vcpu_properties (ARMCPU *cpu);typedef struct ARM64SysReg ARM64SysReg ; +typedef struct ARM64SysRegField ARM64SysRegField ; +typedef struct ARMISARegisters ARMISARegisters ; + +typedef struct ArmFieldRange { +uint64_t min; +uint64_t max; +}ArmFieldRange ; + +typedef struct ArmFieldValueSet { +ArmFieldRange *ranges; +size_t n_ranges; +}ArmFieldValueSet ; + +/** +* arm_field_get_supported_values: +* @field: The field to get the supported values for +* @host_isar: The host ISAR registers +* @value_set: The set of supported values for the @field +* target/arm/kvm_arm.h void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu); · line 174
Quoted 10 lines
target/arm/kvm_arm.h +7
-0+* Will be allocated and filled in with the supported values for the @field +* based on the host_isar and whether the field is writable or not. +* The caller must free the value_set. +*/ +void arm_field_get_supported_values (const ARM64SysRegField *field, +const ARMISARegisters *host_isar, +ArmFieldValueSet **value_set);/** * kvm_arm_steal_time_finalize: Thanks
Eric
Re: [RFC PATCH v3 14/19] target/arm/kvm: compute supported values for ID register fields
Quoted 62 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 41 lines · Khushit Shah
Quoted 11 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Hi Khushit,
On 7/16/26 11:38 PM, Khushit Shah wrote:
Quoted 8 lines
Quoted 7 lines
Add
arm_field_get_supported_values()which, for a given ID register field, builds the set of values KVM allows it to take on the live host.Non-writable fields are pinned to the host value. Writable fields follow their per field constraints. This function likely needs change when KVM starts exposing a new writable field that is not lower-safe, hence, the special handling of TGranX_2/SpecSEI/L1Ip/MIDR/REVIDR/AIDR.
so this looks quite risky.
I agree.
What are your thoughts on having a authoritative list in QEMU of all writable fields? No matter what KVM exposes as writable, actual fields we allow to be writable will be intersection of KVM writable + QEMU writable. When The QEMU list is updated we make sure things like this function is updated.
This get’s rid of cases where we silently support writing to a field. It is similar to x86, QEMU only supports writing to specific CPUID leafs (by the defined Properties) and not just any CPUID leafs.
Quoted 10 lines
Quoted 3 lines
Cross-field constraints are not modelled; for example
ID_AA64ZFR0_EL1is gated by SVE. Reproducing every inter-field dependency in QEMU would only duplicate KVM's logic and drift out of sync with it.Isn't
qmp_query_cpu_model_expansionsufficient? In general upper layers will try to apply raw named models. If ajustements are needed between source and destination, we know field candidate values (either the source or dest one) and this latter can be directly tried usingqmp_query_cpu_model_expansionwrite. On top of thatqmp_query_cpu_model_expansioncan be directly checked against a scratch vcpu reusing the logic implemented at kernel level.Quoted 6 lines
I am not sure if it is acceptable for
query_cpu_model_expansionshould fail if model is not realisable. On at least x86 it does not. It just returns the state which QEMU would request KVM for the given configurations.I need to further study that. I will come back to you.
Quoted 7 lines
Currently with v7 you get:
(QEMU) query-cpu-model-expansion type=full model={"name":"host","props":{"SYSREG_ID_AA64MMFR1_EL1_AFP":0x1}} {"error": {"class": "GenericError", "desc": "failed to apply new value0x1for field AFP (previous is0x0): Invalid argument"}}This can be implemented elsewhere though
Maybe in “cpu-definitions” or preferably adding “usable” to the "cpu-model-expansion” schema?
Warm regards,
Khushit
Quoted 173 lines
Eric
Quoted 171 lines
cpu-definitions is maybe a better candidate for algo you are describing, but it will not take the user overrides into considerations and only say if a base model is usable or not
Quoted 14 lines
Quoted 14 lines
Signed-off-by Khushit Shah <[email protected]>---
target/arm/kvm.c| 99 ++++++++++++++++++++++++++++++++++++++++++++target/arm/kvm_arm.h| 26 ++++++++++++2 files changed, 125 insertions(+)target/arm/kvm.c +0
-0@@ -1262,6 +1262,105 @@ bool kvm_arm_cpu_post_load(ARMCPU *cpu)return true; }Quoted 15 lines
Quoted 4 lines
target/arm/kvm.c +4
-0+static bool arm_field_is_signed (const ARM64SysRegField *field) +{ +return field_matches (field,ID_AA64MMFR0_EL1_IDX ,"TGran4" ) || + field_matches(field, ID_AA64MMFR0_EL1_IDX, "TGran64") ||target/arm/kvm.c bool kvm_arm_cpu_post_load(ARMCPU *cpu) · line 1278
Quoted 10 lines
target/arm/kvm.c +10
-0+field_matches (field,ID_MMFR0_EL1_IDX ,"InnerShr" ) || +field_matches (field,ID_MMFR0_EL1_IDX ,"OuterShr" ) || +field_matches (field,ID_AA64DFR0_EL1_IDX ,"DoubleLock" ) || +field_matches (field,ID_AA64DFR0_EL1_IDX ,"PMUVer" ) || +field_matches (field,ID_DFR0_EL1_IDX ,"PerfMon" ) || +field_matches (field,ID_AA64PFR1_EL1_IDX ,"MTE_frac" ) || +field_matches (field,ID_AA64MMFR4_EL1_IDX ,"E2H0" ) || +field_matches (field,ID_DFR1_EL1_IDX ,"MTPMU" ) || +field_matches (field,ID_AA64PFR0_EL1_IDX ,"FP" ) || +field_matches (field,ID_AA64PFR0_EL1_IDX ,"AdvSIMD" );Can't we extract this from Register.json instead?
AFAIK, There is not signedness data in Register.json
Quoted 14 lines
Quoted 14 lines
target/arm/kvm.c +14
-0+} + +static void ranges_add (GArray *ranges,uint64_t min,uint64_t max) +{ +ArmFieldRange r = { .min = min, .max = max }; +g_array_append_val (ranges, r); +} + +void arm_field_get_supported_values (const ARM64SysRegField *field, +const ARMISARegisters *host_isar, +ArmFieldValueSet **value_set) +{ +bool is_signed =arm_field_is_signed (field); + uint64_t host = extract64(host_isar->idregs[field->index],Quoted 8 lines
target/arm/kvm.c bool kvm_arm_cpu_post_load(ARMCPU *cpu) · line 1299
Quoted 7 lines
target/arm/kvm.c +7
-0+ field->shift, field->length); +GArray *ranges =g_array_new (false, false,sizeof (ArmFieldRange)); + +/* A non-writable field can only ever hold the host value. */ +if (!arm_field_is_writable (field)) { +ranges_add (ranges, host, host); + goto done;you already get this info from
qmp_query_cpu_model_expansionCan you please elaborate how? I thought the current
qmp_query_cpu_model_expansion(Your v6) only returns the writable field.
(I have not yet looked at v7)Quoted 107 lines
Quoted 94 lines
target/arm/kvm.c +64
-0+ } + +if (field_matches (field,ID_AA64MMFR0_EL1_IDX ,"TGran4_2" ) || +field_matches (field,ID_AA64MMFR0_EL1_IDX ,"TGran16_2" ) || +field_matches (field,ID_AA64MMFR0_EL1_IDX ,"TGran64_2" )) { +/* Either support the host value or the "off" value */ +ranges_add (ranges, host, host); +if (host !=1 ) {/* 1 = "off" */ +ranges_add (ranges,1 ,1 ); + } + }else if (field_matches (field,CTR_EL0_IDX ,"L1Ip" )) { +/* Only safe to downgrade to VIPT, other values are reserved. */ +ranges_add (ranges, host, host); +if (host !=2 ) {/* 2 = "VIPT" */ +ranges_add (ranges,2 ,2 ); + } + }else if (field_matches (field,ID_AA64MMFR1_EL1_IDX ,"SpecSEI" ) || +field_matches (field,ID_MMFR4_EL1_IDX ,"SpecSEI" )) { +/* It is safe to upgrade SpecSEI to 1, other values are reserved. */ +ranges_add (ranges, host, host); +if (host !=1 ) { +ranges_add (ranges,1 ,1 ); + } + }else if (field->index ==MIDR_EL1_IDX || + field->index ==REVIDR_EL1_IDX || + field->index ==AIDR_EL1_IDX ) { +/* +* No restriction on value that can be set for implementation ID +* registers fields. +*/ +uint64_t max =0 ; +if (field->length ==64 ) { + max = ~0ULL ; + }else { + max = (1ULL << field->length) -1 ; + } +ranges_add (ranges,0 , max); + }else { +/* +* After handling the special cases, other writable fields are +* either lower-safe or signed lower-safe. +*/ +if (field->arch_vals_count) { +for (uint32_t i =0 ; i < field->arch_vals_count; i++) { +uint64_t av = field->arch_vals[i].value; +int64_t v = is_signed ? +sextract64 (av,0 , field->length) : (int64_t )av; +int64_t hv = is_signed ? +sextract64 (host,0 , field->length) : (int64_t )host; +if (v <= hv) { +ranges_add (ranges, av, av); + } + } + }else { +g_assert (!is_signed);/* No signed field with no arch vals */ +ranges_add (ranges,0 , host); + } + } +done: + *value_set =g_new0 (ArmFieldValueSet,1 ); + (*value_set)->n_ranges = ranges->len; + (*value_set)->ranges = (ArmFieldRange *)g_array_free (ranges, false); +} +static bool arm_field_skip_writeback_always (const ARM64SysRegField *field) {/* target/arm/kvm_arm.h +19
-0@@ -143,6 +143,32 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu);void kvm_arm_add_vcpu_properties (ARMCPU *cpu);typedef struct ARM64SysReg ARM64SysReg ; +typedef struct ARM64SysRegField ARM64SysRegField ; +typedef struct ARMISARegisters ARMISARegisters ; + +typedef struct ArmFieldRange { +uint64_t min; +uint64_t max; +}ArmFieldRange ; + +typedef struct ArmFieldValueSet { +ArmFieldRange *ranges; +size_t n_ranges; +}ArmFieldValueSet ; + +/** +* arm_field_get_supported_values: +* @field: The field to get the supported values for +* @host_isar: The host ISAR registers +* @value_set: The set of supported values for the @field +* target/arm/kvm_arm.h void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu); · line 174
Quoted 10 lines
target/arm/kvm_arm.h +7
-0+* Will be allocated and filled in with the supported values for the @field +* based on the host_isar and whether the field is writable or not. +* The caller must free the value_set. +*/ +void arm_field_get_supported_values (const ARM64SysRegField *field, +const ARMISARegisters *host_isar, +ArmFieldValueSet **value_set);/** * kvm_arm_steal_time_finalize: Thanks
Eric
RFC PATCH v3 15/19 target/arm/kvm: introduce kvm_arm_get_host_isar helper
In reply to Khushit ShahIntroduce kvm_arm_get_host_isar() to provide scratch vCPU probed host isar. Will be used in future commits.
--- target/arm/kvm-stub.c | 5 +++++ target/arm/kvm.c | 8 ++++++++ target/arm/kvm_arm.h | 4 ++++ 3 files changed, 17 insertions(+)
target/arm/kvm-stub.c +5 -0
@@ -119,3 +119,8 @@ char *kvm_print_register_name(uint64_t regidx) {g_assert_not_reached (); } + +const ARMISARegisters *kvm_arm_get_host_isar (void ) +{ +return NULL ; +}
target/arm/kvm.c +8 -0
@@ -650,6 +650,14 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) env->features = arm_host_cpu_features.features; } +const ARMISARegisters *kvm_arm_get_host_isar (void ) +{ +if (!arm_host_cpu_features.dtb_compatible) { +kvm_arm_get_host_cpu_features (&arm_host_cpu_features); + } +return &arm_host_cpu_features.isar; +} +static bool kvm_no_adjvtime_get (Object *obj,Error **errp) {return !ARM_CPU (obj)->kvm_adjvtime;
target/arm/kvm_arm.h +4 -0
@@ -15,6 +15,8 @@#include "system/kvm.h" #include "target/arm/cpu-qom.h" +typedef struct ARMISARegisters ARMISARegisters ; +#define KVM_ARM_VGIC_V2 (1 << 0)#define KVM_ARM_VGIC_V3 (1 << 1)
@@ -257,6 +259,8 @@ void kvm_arm_enable_mte(Object *cpuobj, Error **errp);void arm_cpu_kvm_set_irq (void *arm_cpu,int irq,int level); +const ARMISARegisters *kvm_arm_get_host_isar (void ); +void arm_gic_cap_kvm_probe (GICCapability *v2,GICCapability *v3);/*
Signature · 1 line
2.52.0
RFC PATCH v3 16/19 qmp: add query-cpu-props-info command
In reply to Khushit ShahIntroduce the 'query-cpu-props-info' QMP command. For CPU model properties it reports the type (boolean or number) and the set of values supported under the active accelerator and host.
For numbers the supported values are expressed as a list of inclusive {min, max} ranges; for booleans as the list of allowed true/false values.
The command and its return types (CpuPropertyType, CpuPropertyInfo and friends) are defined in qapi/machine.json rather than an Arm-specific schema, since the concept applies to other targets (e.g. x86, riscv) too. Target that do not implement it return an error.
The Arm/KVM implementation spins up a scratch "host" vCPU object, walks its QOM properties: SYSREG_ ID-register fields become 'number' properties whose ranges come from arm_field_get_supported_values(), and the advertised feature toggles become 'boolean' properties.
--- qapi/machine.json | 87 ++++++++++++++++++++++++++++++++++++ stubs/meson.build | 1 + stubs/qmp-cpu-props-info.c | 12 +++++ target/arm/arm-qmp-cmds.c | 90 ++++++++++++++++++++++++++++++++++++++ target/arm/kvm-stub.c | 7 +++ 5 files changed, 197 insertions(+) create mode 100644 stubs/qmp-cpu-props-info.c
qapi/machine.json +87 -0
@@ -2251,3 +2251,90 @@ # Since: 1.2 ## { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'] } + +## +# @CpuPropertyType: +# +# The type of a CPU model property value. +# +# @boolean: the property is an on/off toggle. +# +# @number: the property is an unsigned integer. +# +# Since: 11.1 +## +{ 'enum': 'CpuPropertyType', + 'data': [ 'boolean', 'number' ] } + +## +# @CpuPropertyValueRange: +# +# An inclusive range of numeric values supported for a property. +# +# @min: the lowest supported value. +# +# @max: the highest supported value. +# +# Since: 11.1 +## +{ 'struct': 'CpuPropertyValueRange', + 'data': { 'min': 'uint64', 'max': 'uint64' } } + +## +# @CpuPropertyInfoBoolean: +# +# @supported-values: the boolean values the host supports for this +# property (a subset of {true, false}). +# +# Since: 11.1 +## +{ 'struct': 'CpuPropertyInfoBoolean', + 'data': { 'supported-values': ['bool'] } } + +## +# @CpuPropertyInfoNumber: +# +# @supported-values: the set of value ranges the host supports for +# this property. +# +# Since: 11.1 +## +{ 'struct': 'CpuPropertyInfoNumber', + 'data': { 'supported-values': ['CpuPropertyValueRange'] } } + +## +# @CpuPropertyInfo: +# +# Information about a single CPU model property, including the values +# the current host supports for it. +# +# @name: the name of the property. +# +# @type: the type of the property, which selects the layout of +# @supported-values. +# +# Since: 11.1 +## +{ 'union': 'CpuPropertyInfo', + 'base': { 'name': 'str', + 'type': 'CpuPropertyType' }, + 'discriminator': 'type', + 'data': { 'boolean': 'CpuPropertyInfoBoolean', + 'number': 'CpuPropertyInfoNumber' } } + +## +# @query-cpu-props-info: +# +# Return information about the CPU model properties. For each +# property it reports the values supported under the active +# accelerator and host. +# +# .. note:: This command is currently only implemented on Arm (and +# KVM accel); all other configurations return an error. The schema +# is architecture-agnostic so other targets and accelerators can +# implement it in the future. +# +# Since: 11.1 +## +{ 'command': 'query-cpu-props-info', + 'returns': ['CpuPropertyInfo'] }
stubs/meson.build +1 -0
@@ -83,6 +83,7 @@ if have_system stub_ss.add(files('qmp-i386-sgx.c')) stub_ss.add(files('qmp-i386-xen.c')) stub_ss.add(files('qmp-cpu.c')) + stub_ss.add(files('qmp-cpu-props-info.c')) stub_ss.add(files('qmp-cpu-s390x.c')) stub_ss.add(files('qmp-cpu-s390x-kvm.c')) stub_ss.add(files('hmp-cmd-info_mem.c'))
stubs/qmp-cpu-props-info.c new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-machine.h" + +CpuPropertyInfoList * +qmp_query_cpu_props_info (Error **errp) +{ +error_setg (errp,"CPU model properties are not supported on this target" ); +return NULL ; +}
target/arm/arm-qmp-cmds.c +90 -0
96 lines not on this page · raw message
target/arm/kvm-stub.c +7 -0
@@ -124,3 +124,10 @@ const ARMISARegisters *kvm_arm_get_host_isar(void) {return NULL ; } + +void arm_field_get_supported_values (const ARM64SysRegField *field, +const ARMISARegisters *host_isar, +ArmFieldValueSet **value_set) +{ +g_assert_not_reached (); +}
Signature · 1 line
2.52.0
Re: [RFC PATCH v3 16/19] qmp: add query-cpu-props-info command
Series doesn't apply for me. I need to apply it to be able to check rendered documentation. Could you push it somewhere I can pull?
Re: [RFC PATCH v3 16/19] qmp: add query-cpu-props-info command
Quoted 12 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Series doesn't apply for me. I need to apply it to be able to check rendered documentation. Could you push it somewhere I can pull?
Sorry for the late reply,
Please use the following branch: https://github.com/khushit-shah-nx/qemu/tree/upstream-rfc-v3-fixups
Re: [RFC PATCH v3 16/19] qmp: add query-cpu-props-info command
Quoted 5 lines · Khushit Shah
Quoted 5 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email
Quoted 8 lines
Quoted 5 lines
|-------------------------------------------------------------------!
Series doesn't apply for me. I need to apply it to be able to check rendered documentation. Could you push it somewhere I can pull?
Sorry for the late reply,
Please use the following branch: https://github.com/khushit-shah-nx/qemu/tree/upstream-rfc-v3-fixups
Doesn't compile for me:
FAILED: [code=1] qemu-aarch64_be
cc -m64 -o qemu-aarch64_be libcommon.a.p/accel_accel-common.c.o libcommon.a.p/hw_core_cpu-common.c.o libcommon.a.p/hw_core_machine-smp.c.o libcommon.a.p/cpu-common.c.o libcommon.a.p/page-vary-common.c.o libcommon.a.p/target-info.c.o libcommon.a.p/disas_capstone.c.o libcommon.a.p/disas_disas-host.c.o libcommon.a.p/disas_disas-target.c.o libcommon.a.p/disas_objdump.c.o libcommon.a.p/disas_disas-common.c.o libcommon.a.p/fpu_softfloat.c.o libcommon.a.p/plugins_loader.c.o libcommon.a.p/meson-generated_.._gdbstub_gdbstub-xml.c.o libcommon_arm.a.p/target_arm_mmuidx.c.o libcommon_arm.a.p/target_arm_tcg_arith_helper.c.o libcommon_arm.a.p/target_arm_tcg_crypto_helper.c.o libuser.a.p/semihosting_user.c.o libuser.a.p/semihosting_guestfd.c.o libuser.a.p/accel_accel-user.c.o libuser.a.p/accel_tcg_cpu-exec.c.o libuser.a.p/accel_tcg_cpu-exec-common.c.o libuser.a.p/accel_tcg_tcg-runtime.c.o libuser.a.p/accel_tcg_tcg-runtime-gvec.c.o libuser.a.p/accel_tcg_tb-maint.c.o libuser.a.p/accel_tcg_tcg-all.c.o libuser.a.p/accel_tcg_tcg-stats.c.o libuser.a.p/accel_tcg_translate-all.c.o libuser.a.p/accel_tcg_translator.c.o libuser.a.p/accel_tcg_plugin-gen.c.o libuser.a.p/accel_tcg_user-exec.c.o libuser.a.p/accel_tcg_user-exec-stub.c.o libuser.a.p/hw_core_cpu-user.c.o libuser.a.p/hw_core_qdev-user.c.o libuser.a.p/gdbstub_gdbstub.c.o libuser.a.p/gdbstub_syscalls.c.o libuser.a.p/gdbstub_user.c.o libuser.a.p/cpu-target.c.o libuser.a.p/tcg_optimize.c.o libuser.a.p/tcg_region.c.o libuser.a.p/tcg_tcg.c.o libuser.a.p/tcg_tcg-common.c.o libuser.a.p/tcg_tcg-op.c.o libuser.a.p/tcg_tcg-op-ldst.c.o libuser.a.p/tcg_tcg-op-gvec.c.o libuser.a.p/tcg_tcg-op-vec.c.o libuser.a.p/tcg_debuginfo.c.o libuser.a.p/tcg_perf.c.o libuser.a.p/plugins_user.c.o libuser.a.p/plugins_api-user.c.o libuser.a.p/plugins_api.c.o libuser.a.p/plugins_core.c.o libuser.a.p/common-user_safe-syscall.S.o libuser.a.p/common-user_safe-syscall-error.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_gdbstub.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_cpu.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_cpregs-gcs.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_cpregs-pmu.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_debug_helper.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_helper.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_vfp_fpscr.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_el2-stubs.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_cpregs-omap-stub.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_common-semi-target.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_debug.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_gengvec.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_hflags.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_m_helper.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_mve_helper.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_neon_helper.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_op_helper.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_tlb_helper.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate-m-nocp.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate-mve.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate-neon.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate-vfp.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_vec_helper.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_vfp_helper.c.o libqemu-aarch64_be-linux-user.a.p/linux-user_aarch64_cpu_loop.c.o libqemu-aarch64_be-linux-user.a.p/linux-user_aarch64_elfload.c.o libqemu-aarch64_be-linux-user.a.p/linux-user_aarch64_signal.c.o libqemu-aarch64_be-linux-user.a.p/target-info-stub.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_cpu64.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_gdbstub64.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_cpu32.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_cpu64.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_gengvec64.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate-a64.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate-sve.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate-sme.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_helper-a64.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_mte_helper.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_pauth_helper.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_sme_helper.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_sve_helper.c.o libqemu-aarch64_be-linux-user.a.p/target_arm_tcg_vec_helper64.c.o libqemu-aarch64_be-linux-user.a.p/semihosting_syscalls.c.o libqemu-aarch64_be-linux-user.a.p/semihosting_arm-compat-semi.c.o libqemu-aarch64_be-linux-user.a.p/accel_accel-target.c.o libqemu-aarch64_be-linux-user.a.p/hw_intc_arm_gicv3_hvf_stub.c.o libqemu-aarch64_be-linux-user.a.p/gdbstub_user-target.c.o libqemu-aarch64_be-linux-user.a.p/linux-user_elfload.c.o libqemu-aarch64_be-linux-user.a.p/linux-user_exit.c.o libqemu-aarch64_be-linux-user.a.p/linux-user_fd-trans.c.o libqemu-aarch64_be-linux-user.a.p/linux-user_linuxload.c.o libqemu-aarch64_be-linux-user.a.p/linux-user_main.c.o libqemu-aarch64_be-linux-user.a.p/linux-user_mmap.c.o libqemu-aarch64_be-linux-user.a.p/linux-user_signal.c.o libqemu-aarch64_be-linux-user.a.p/linux-user_strace.c.o libqemu-aarch64_be-linux-user.a.p/linux-user_syscall.c.o libqemu-aarch64_be-linux-user.a.p/linux-user_thunk.c.o libqemu-aarch64_be-linux-user.a.p/linux-user_uaccess.c.o libqemu-aarch64_be-linux-user.a.p/linux-user_uname.c.o libqemu-aarch64_be-linux-user.a.p/linux-user_flatload.c.o libqemu-aarch64_be-linux-user.a.p/linux-user_semihost.c.o libqemu-aarch64_be-linux-user.a.p/linux-user_plugin-api.c.o libqemu-aarch64_be-linux-user.a.p/linux-user_aarch64_mte_user_helper.c.o libhwcore.a.p/hw_core_bus.c.o libhwcore.a.p/hw_core_gpio.c.o libhwcore.a.p/hw_core_qdev-properties.c.o libhwcore.a.p/hw_core_qdev.c.o libhwcore.a.p/hw_core_resetcontainer.c.o libhwcore.a.p/hw_core_resettable.c.o libhwcore.a.p/hw_core_vmstate-if.c.o libhwcore.a.p/hw_core_irq.c.o libhwcore.a.p/hw_core_clock.c.o libhwcore.a.p/hw_core_qdev-clock.c.o libqom.a.p/qom_container.c.o libqom.a.p/qom_object.c.o libqom.a.p/qom_object_interfaces.c.o libqom.a.p/qom_qom-qobject.c.o libqom.a.p/qom_compat-properties.c.o libevent-loop-base.a.p/event-loop-base.c.o -Wl,--as-needed -Wl,--no-undefined -pie -fstack-protector-strong -Wl,-z,relro -Wl,-z,now -Wl,--start-group libqemuutil.a subprojects/libvhost-user/libvhost-user-glib.a subprojects/libvhost-user/libvhost-user.a libstubs_arm.a -Xlinker --dynamic-list=/work/armbru/qemu/bld/plugins/qemu-plugin.symbols /usr/lib64/libcapstone.so /usr/lib64/libz.so /usr/lib64/libdw.so /usr/lib64/libelf.so -lnuma /usr/lib64/liburing.so /usr/lib64/libgio-2.0.so /usr/lib64/libgobject-2.0.so /usr/lib64/libglib-2.0.so /usr/lib64/libgmodule-2.0.so -pthread /usr/lib64/libgnutls.so -lm /usr/lib64/libpixman-1.so /usr/lib64/libepoxy.so -Wl,--end-group /usr/bin/ld: libqemu-aarch64_be-linux-user.a.p/target_arm_cpu64.c.o: in function `arm_cpu_sve_finalize':
/work/armbru/qemu/bld/../target/arm/cpu64.c:146:(.text+0x11f2): undefined reference to `arm_find_model'/usr/bin/ld: libqemu-aarch64_be-linux-user.a.p/target_arm_cpu64.c.o: in function `arm_cpu_pauth_finalize':
/work/armbru/qemu/bld/../target/arm/cpu64.c:583:(.text+0x1a55): undefined reference to `arm_find_model'
collect2: error: ld returned 1 exit status
[6689/7247] Linking target qemu-aarch64
FAILED: [code=1] qemu-aarch64
cc -m64 -o qemu-aarch64 libcommon.a.p/accel_accel-common.c.o libcommon.a.p/hw_core_cpu-common.c.o libcommon.a.p/hw_core_machine-smp.c.o libcommon.a.p/cpu-common.c.o libcommon.a.p/page-vary-common.c.o libcommon.a.p/target-info.c.o libcommon.a.p/disas_capstone.c.o libcommon.a.p/disas_disas-host.c.o libcommon.a.p/disas_disas-target.c.o libcommon.a.p/disas_objdump.c.o libcommon.a.p/disas_disas-common.c.o libcommon.a.p/fpu_softfloat.c.o libcommon.a.p/plugins_loader.c.o libcommon.a.p/meson-generated_.._gdbstub_gdbstub-xml.c.o libcommon_arm.a.p/target_arm_mmuidx.c.o libcommon_arm.a.p/target_arm_tcg_arith_helper.c.o libcommon_arm.a.p/target_arm_tcg_crypto_helper.c.o libuser.a.p/semihosting_user.c.o libuser.a.p/semihosting_guestfd.c.o libuser.a.p/accel_accel-user.c.o libuser.a.p/accel_tcg_cpu-exec.c.o libuser.a.p/accel_tcg_cpu-exec-common.c.o libuser.a.p/accel_tcg_tcg-runtime.c.o libuser.a.p/accel_tcg_tcg-runtime-gvec.c.o libuser.a.p/accel_tcg_tb-maint.c.o libuser.a.p/accel_tcg_tcg-all.c.o libuser.a.p/accel_tcg_tcg-stats.c.o libuser.a.p/accel_tcg_translate-all.c.o libuser.a.p/accel_tcg_translator.c.o libuser.a.p/accel_tcg_plugin-gen.c.o libuser.a.p/accel_tcg_user-exec.c.o libuser.a.p/accel_tcg_user-exec-stub.c.o libuser.a.p/hw_core_cpu-user.c.o libuser.a.p/hw_core_qdev-user.c.o libuser.a.p/gdbstub_gdbstub.c.o libuser.a.p/gdbstub_syscalls.c.o libuser.a.p/gdbstub_user.c.o libuser.a.p/cpu-target.c.o libuser.a.p/tcg_optimize.c.o libuser.a.p/tcg_region.c.o libuser.a.p/tcg_tcg.c.o libuser.a.p/tcg_tcg-common.c.o libuser.a.p/tcg_tcg-op.c.o libuser.a.p/tcg_tcg-op-ldst.c.o libuser.a.p/tcg_tcg-op-gvec.c.o libuser.a.p/tcg_tcg-op-vec.c.o libuser.a.p/tcg_debuginfo.c.o libuser.a.p/tcg_perf.c.o libuser.a.p/plugins_user.c.o libuser.a.p/plugins_api-user.c.o libuser.a.p/plugins_api.c.o libuser.a.p/plugins_core.c.o libuser.a.p/common-user_safe-syscall.S.o libuser.a.p/common-user_safe-syscall-error.c.o libqemu-aarch64-linux-user.a.p/target_arm_gdbstub.c.o libqemu-aarch64-linux-user.a.p/target_arm_cpu.c.o libqemu-aarch64-linux-user.a.p/target_arm_cpregs-gcs.c.o libqemu-aarch64-linux-user.a.p/target_arm_cpregs-pmu.c.o libqemu-aarch64-linux-user.a.p/target_arm_debug_helper.c.o libqemu-aarch64-linux-user.a.p/target_arm_helper.c.o libqemu-aarch64-linux-user.a.p/target_arm_vfp_fpscr.c.o libqemu-aarch64-linux-user.a.p/target_arm_el2-stubs.c.o libqemu-aarch64-linux-user.a.p/target_arm_cpregs-omap-stub.c.o libqemu-aarch64-linux-user.a.p/target_arm_common-semi-target.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_debug.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_gengvec.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_hflags.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_m_helper.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_mve_helper.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_neon_helper.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_op_helper.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_tlb_helper.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_translate.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_translate-m-nocp.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_translate-mve.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_translate-neon.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_translate-vfp.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_vec_helper.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_vfp_helper.c.o libqemu-aarch64-linux-user.a.p/linux-user_aarch64_cpu_loop.c.o libqemu-aarch64-linux-user.a.p/linux-user_aarch64_elfload.c.o libqemu-aarch64-linux-user.a.p/linux-user_aarch64_signal.c.o libqemu-aarch64-linux-user.a.p/target-info-stub.c.o libqemu-aarch64-linux-user.a.p/target_arm_cpu64.c.o libqemu-aarch64-linux-user.a.p/target_arm_gdbstub64.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_cpu32.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_cpu64.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_gengvec64.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_translate-a64.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_translate-sve.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_translate-sme.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_helper-a64.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_mte_helper.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_pauth_helper.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_sme_helper.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_sve_helper.c.o libqemu-aarch64-linux-user.a.p/target_arm_tcg_vec_helper64.c.o libqemu-aarch64-linux-user.a.p/semihosting_syscalls.c.o libqemu-aarch64-linux-user.a.p/semihosting_arm-compat-semi.c.o libqemu-aarch64-linux-user.a.p/accel_accel-target.c.o libqemu-aarch64-linux-user.a.p/hw_intc_arm_gicv3_hvf_stub.c.o libqemu-aarch64-linux-user.a.p/gdbstub_user-target.c.o libqemu-aarch64-linux-user.a.p/linux-user_elfload.c.o libqemu-aarch64-linux-user.a.p/linux-user_exit.c.o libqemu-aarch64-linux-user.a.p/linux-user_fd-trans.c.o libqemu-aarch64-linux-user.a.p/linux-user_linuxload.c.o libqemu-aarch64-linux-user.a.p/linux-user_main.c.o libqemu-aarch64-linux-user.a.p/linux-user_mmap.c.o libqemu-aarch64-linux-user.a.p/linux-user_signal.c.o libqemu-aarch64-linux-user.a.p/linux-user_strace.c.o libqemu-aarch64-linux-user.a.p/linux-user_syscall.c.o libqemu-aarch64-linux-user.a.p/linux-user_thunk.c.o libqemu-aarch64-linux-user.a.p/linux-user_uaccess.c.o libqemu-aarch64-linux-user.a.p/linux-user_uname.c.o libqemu-aarch64-linux-user.a.p/linux-user_flatload.c.o libqemu-aarch64-linux-user.a.p/linux-user_semihost.c.o libqemu-aarch64-linux-user.a.p/linux-user_plugin-api.c.o libqemu-aarch64-linux-user.a.p/linux-user_aarch64_mte_user_helper.c.o libhwcore.a.p/hw_core_bus.c.o libhwcore.a.p/hw_core_gpio.c.o libhwcore.a.p/hw_core_qdev-properties.c.o libhwcore.a.p/hw_core_qdev.c.o libhwcore.a.p/hw_core_resetcontainer.c.o libhwcore.a.p/hw_core_resettable.c.o libhwcore.a.p/hw_core_vmstate-if.c.o libhwcore.a.p/hw_core_irq.c.o libhwcore.a.p/hw_core_clock.c.o libhwcore.a.p/hw_core_qdev-clock.c.o libqom.a.p/qom_container.c.o libqom.a.p/qom_object.c.o libqom.a.p/qom_object_interfaces.c.o libqom.a.p/qom_qom-qobject.c.o libqom.a.p/qom_compat-properties.c.o libevent-loop-base.a.p/event-loop-base.c.o -Wl,--as-needed -Wl,--no-undefined -pie -fstack-protector-strong -Wl,-z,relro -Wl,-z,now -Wl,--start-group libqemuutil.a subprojects/libvhost-user/libvhost-user-glib.a subprojects/libvhost-user/libvhost-user.a libstubs_arm.a -Xlinker --dynamic-list=/work/armbru/qemu/bld/plugins/qemu-plugin.symbols /usr/lib64/libcapstone.so /usr/lib64/libz.so /usr/lib64/libdw.so /usr/lib64/libelf.so -lnuma /usr/lib64/liburing.so /usr/lib64/libgio-2.0.so /usr/lib64/libgobject-2.0.so /usr/lib64/libglib-2.0.so /usr/lib64/libgmodule-2.0.so -pthread /usr/lib64/libgnutls.so -lm /usr/lib64/libpixman-1.so /usr/lib64/libepoxy.so -Wl,--end-group /usr/bin/ld: libqemu-aarch64-linux-user.a.p/target_arm_cpu64.c.o: in function `arm_cpu_sve_finalize':
/work/armbru/qemu/bld/../target/arm/cpu64.c:146:(.text+0x11f2): undefined reference to `arm_find_model'/usr/bin/ld: libqemu-aarch64-linux-user.a.p/target_arm_cpu64.c.o: in function `arm_cpu_pauth_finalize':
/work/armbru/qemu/bld/../target/arm/cpu64.c:583:(.text+0x1a55): undefined reference to `arm_find_model'
collect2: error: ld returned 1 exit status
Re: [RFC PATCH v3 16/19] qmp: add query-cpu-props-info command
Quoted 18 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 7 lines · Khushit Shah
Quoted 7 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Series doesn't apply for me. I need to apply it to be able to check rendered documentation. Could you push it somewhere I can pull?
Sorry for the late reply,
Please use the following branch: https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_khushit-2Dshah-2Dnx_qemu_tree_upstream-2Drfc-2Dv3-2Dfixups&d=DwIFaQ&c=s883GpUCOChKOHiocYtGcg&r=PGWMyignA0NiDmTlyP7vOTHozBws_VN86yrVmSMkBp0&m=jlEKINn7T9VpWSJkWeOuzIpFt5Hs3kXB6PwWQoiRYhHwkovj5haqCBtYIV_Ds1EQ&s=7QmSEQKWrSTCnV-3Crq1zl_IHQGCiY6VpAmFXqbCb9s&e=Doesn't compile for me:
Wow, extremely sorry for this, will take a look.
Quoted 15 lines
FAILED: [code=1] qemu-aarch64_be
cc -m64 -o qemu-aarch64_belibcommon.a.p/accel_accel-common.c.olibcommon.a.p/hw_core_cpu-common.c.olibcommon.a.p/hw_core_machine-smp.c.olibcommon.a.p/cpu-common.c.olibcommon.a.p/page-vary-common.c.olibcommon.a.p/target-info.c.olibcommon.a.p/disas_capstone.c.olibcommon.a.p/disas_disas-host.c.olibcommon.a.p/disas_disas-target.c.olibcommon.a.p/disas_objdump.c.olibcommon.a.p/disas_disas-common.c.olibcommon.a.p/fpu_softfloat.c.olibcommon.a.p/plugins_loader.c.olibcommon.a.p/meson-generated_.._gdbstub_gdbstub-xml.c.olibcommon_arm.a.p/target_arm_mmuidx.c.olibcommon_arm.a.p/target_arm_tcg_arith_helper.c.olibcommon_arm.a.p/target_arm_tcg_crypto_helper.c.olibuser.a.p/semihosting_user.c.olibuser.a.p/semihosting_guestfd.c.olibuser.a.p/accel_accel-user.c.olibuser.a.p/accel_tcg_cpu-exec.c.olibuser.a.p/accel_tcg_cpu-exec-common.c.olibuser.a.p/accel_tcg_tcg-runtime.c.olibuser.a.p/accel_tcg_tcg-runtime-gvec.c.olibuser.a.p/accel_tcg_tb-maint.c.olibuser.a.p/accel_tcg_tcg-all.c.olibuser.a.p/accel_tcg_tcg-stats.c.olibuser.a.p/accel_tcg_translate-all.c.olibuser.a.p/accel_tcg_translator.c.olibuser.a.p/accel_tcg_plugin-gen.c.olibuser.a.p/accel_tcg_user-exec.c.olibuser.a.p/accel_tcg_user-exec-stub.c.olibuser.a.p/hw_core_cpu-user.c.olibuser.a.p/hw_core_qdev-user.c.olibuser.a.p/gdbstub_gdbstub.c.olibuser.a.p/gdbstub_syscalls.c.olibuser.a.p/gdbstub_user.c.olibuser.a.p/cpu-target.c.olibuser.a.p/tcg_optimize.c.olibuser.a.p/tcg_region.c.olibuser.a.p/tcg_tcg.c.olibuser.a.p/tcg_tcg-common.c.olibuser.a.p/tcg_tcg-op.c.olibuser.a.p/tcg_tcg-op-ldst.c.olibuser.a.p/tcg_tcg-op-gvec.c.olibuser.a.p/tcg_tcg-op-vec.c.olibuser.a.p/tcg_debuginfo.c.olibuser.a.p/tcg_perf.c.olibuser.a.p/plugins_user.c.olibuser.a.p/plugins_api-user.c.olibuser.a.p/plugins_api.c.olibuser.a.p/plugins_core.c.olibuser.a.p/common-user_safe-syscall.S.olibuser.a.p/common-user_safe-syscall-error.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_gdbstub.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_cpu.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_cpregs-gcs.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_cpregs-pmu.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_debug_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_vfp_fpscr.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_el2-stubs.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_cpregs-omap-stub.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_common-semi-target.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_debug.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_gengvec.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_hflags.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_m_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_mve_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_neon_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_op_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_tlb_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate-m-nocp.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate-mve.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate-neon.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate-vfp.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_vec_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_vfp_helper.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_aarch64_cpu_loop.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_aarch64_elfload.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_aarch64_signal.c.olibqemu-aarch64_be-linux-user.a.p/target-info-stub.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_cpu64.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_gdbstub64.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_cpu32.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_cpu64.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_gengvec64.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate-a64.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate-sve.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate-sme.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_helper-a64.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_mte_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_pauth_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_sme_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_sve_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_vec_helper64.c.olibqemu-aarch64_be-linux-user.a.p/semihosting_syscalls.c.olibqemu-aarch64_be-linux-user.a.p/semihosting_arm-compat-semi.c.olibqemu-aarch64_be-linux-user.a.p/accel_accel-target.c.olibqemu-aarch64_be-linux-user.a.p/hw_intc_arm_gicv3_hvf_stub.c.olibqemu-aarch64_be-linux-user.a.p/gdbstub_user-target.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_elfload.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_exit.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_fd-trans.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_linuxload.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_main.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_mmap.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_signal.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_strace.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_syscall.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_thunk.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_uaccess.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_uname.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_flatload.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_semihost.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_plugin-api.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_aarch64_mte_user_helper.c.olibhwcore.a.p/hw_core_bus.c.olibhwcore.a.p/hw_core_gpio.c.olibhwcore.a.p/hw_core_qdev-properties.c.olibhwcore.a.p/hw_core_qdev.c.olibhwcore.a.p/hw_core_resetcontainer.c.olibhwcore.a.p/hw_core_resettable.c.olibhwcore.a.p/hw_core_vmstate-if.c.olibhwcore.a.p/hw_core_irq.c.olibhwcore.a.p/hw_core_clock.c.olibhwcore.a.p/hw_core_qdev-clock.c.olibqom.a.p/qom_container.c.olibqom.a.p/qom_object.c.olibqom.a.p/qom_object_interfaces.c.olibqom.a.p/qom_qom-qobject.c.olibqom.a.p/qom_compat-properties.c.olibevent-loop-base.a.p/event-loop-base.c.o-Wl,--as-needed -Wl,--no-undefined -pie -fstack-protector-strong -Wl,-z,relro -Wl,-z,now -Wl,--start-group libqemuutil.a subprojects/libvhost-user/libvhost-user-glib.a subprojects/libvhost-user/libvhost-user.a libstubs_arm.a -Xlinker --dynamic-list=/work/armbru/qemu/bld/plugins/qemu-plugin.symbols/usr/lib64/libcapstone.so/usr/lib64/libz.so/usr/lib64/libdw.so/usr/lib64/libelf.so-lnuma/usr/lib64/liburing.so/usr/lib64/libgio-2.0.so/usr/lib64/libgobject-2.0.so/usr/lib64/libglib-2.0.so/usr/lib64/libgmodule-2.0.so-pthread/usr/lib64/libgnutls.so-lm/usr/lib64/libpixman-1.so/usr/lib64/libepoxy.so-Wl,--end-group/usr/bin/ld:libqemu-aarch64_be-linux-user.a.p/target_arm_cpu64.c.o: in function `arm_cpu_sve_finalize':
/work/armbru/qemu/bld/../target/arm/cpu64.c:146:(.text+0x11f2): undefined reference to `arm_find_model'/usr/bin/ld:libqemu-aarch64_be-linux-user.a.p/target_arm_cpu64.c.o: in function `arm_cpu_pauth_finalize':
/work/armbru/qemu/bld/../target/arm/cpu64.c:583:(.text+0x1a55): undefined reference to `arm_find_model'
collect2: error: ld returned 1 exit status
[6689/7247] Linking target qemu-aarch64
FAILED: [code=1] qemu-aarch64
cc -m64 -o qemu-aarch64libcommon.a.p/accel_accel-common.c.olibcommon.a.p/hw_core_cpu-common.c.olibcommon.a.p/hw_core_machine-smp.c.olibcommon.a.p/cpu-common.c.olibcommon.a.p/page-vary-common.c.olibcommon.a.p/target-info.c.olibcommon.a.p/disas_capstone.c.olibcommon.a.p/disas_disas-host.c.olibcommon.a.p/disas_disas-target.c.olibcommon.a.p/disas_objdump.c.olibcommon.a.p/disas_disas-common.c.olibcommon.a.p/fpu_softfloat.c.olibcommon.a.p/plugins_loader.c.olibcommon.a.p/meson-generated_.._gdbstub_gdbstub-xml.c.olibcommon_arm.a.p/target_arm_mmuidx.c.olibcommon_arm.a.p/target_arm_tcg_arith_helper.c.olibcommon_arm.a.p/target_arm_tcg_crypto_helper.c.olibuser.a.p/semihosting_user.c.olibuser.a.p/semihosting_guestfd.c.olibuser.a.p/accel_accel-user.c.olibuser.a.p/accel_tcg_cpu-exec.c.olibuser.a.p/accel_tcg_cpu-exec-common.c.olibuser.a.p/accel_tcg_tcg-runtime.c.olibuser.a.p/accel_tcg_tcg-runtime-gvec.c.olibuser.a.p/accel_tcg_tb-maint.c.olibuser.a.p/accel_tcg_tcg-all.c.olibuser.a.p/accel_tcg_tcg-stats.c.olibuser.a.p/accel_tcg_translate-all.c.olibuser.a.p/accel_tcg_translator.c.olibuser.a.p/accel_tcg_plugin-gen.c.olibuser.a.p/accel_tcg_user-exec.c.olibuser.a.p/accel_tcg_user-exec-stub.c.olibuser.a.p/hw_core_cpu-user.c.olibuser.a.p/hw_core_qdev-user.c.olibuser.a.p/gdbstub_gdbstub.c.olibuser.a.p/gdbstub_syscalls.c.olibuser.a.p/gdbstub_user.c.olibuser.a.p/cpu-target.c.olibuser.a.p/tcg_optimize.c.olibuser.a.p/tcg_region.c.olibuser.a.p/tcg_tcg.c.olibuser.a.p/tcg_tcg-common.c.olibuser.a.p/tcg_tcg-op.c.olibuser.a.p/tcg_tcg-op-ldst.c.olibuser.a.p/tcg_tcg-op-gvec.c.olibuser.a.p/tcg_tcg-op-vec.c.olibuser.a.p/tcg_debuginfo.c.olibuser.a.p/tcg_perf.c.olibuser.a.p/plugins_user.c.olibuser.a.p/plugins_api-user.c.olibuser.a.p/plugins_api.c.olibuser.a.p/plugins_core.c.olibuser.a.p/common-user_safe-syscall.S.olibuser.a.p/common-user_safe-syscall-error.c.olibqemu-aarch64-linux-user.a.p/target_arm_gdbstub.c.olibqemu-aarch64-linux-user.a.p/target_arm_cpu.c.olibqemu-aarch64-linux-user.a.p/target_arm_cpregs-gcs.c.olibqemu-aarch64-linux-user.a.p/target_arm_cpregs-pmu.c.olibqemu-aarch64-linux-user.a.p/target_arm_debug_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_vfp_fpscr.c.olibqemu-aarch64-linux-user.a.p/target_arm_el2-stubs.c.olibqemu-aarch64-linux-user.a.p/target_arm_cpregs-omap-stub.c.olibqemu-aarch64-linux-user.a.p/target_arm_common-semi-target.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_debug.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_gengvec.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_hflags.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_m_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_mve_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_neon_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_op_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_tlb_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_translate.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_translate-m-nocp.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_translate-mve.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_translate-neon.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_translate-vfp.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_vec_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_vfp_helper.c.olibqemu-aarch64-linux-user.a.p/linux-user_aarch64_cpu_loop.c.olibqemu-aarch64-linux-user.a.p/linux-user_aarch64_elfload.c.olibqemu-aarch64-linux-user.a.p/linux-user_aarch64_signal.c.olibqemu-aarch64-linux-user.a.p/target-info-stub.c.olibqemu-aarch64-linux-user.a.p/target_arm_cpu64.c.olibqemu-aarch64-linux-user.a.p/target_arm_gdbstub64.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_cpu32.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_cpu64.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_gengvec64.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_translate-a64.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_translate-sve.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_translate-sme.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_helper-a64.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_mte_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_pauth_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_sme_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_sve_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_vec_helper64.c.olibqemu-aarch64-linux-user.a.p/semihosting_syscalls.c.olibqemu-aarch64-linux-user.a.p/semihosting_arm-compat-semi.c.olibqemu-aarch64-linux-user.a.p/accel_accel-target.c.olibqemu-aarch64-linux-user.a.p/hw_intc_arm_gicv3_hvf_stub.c.olibqemu-aarch64-linux-user.a.p/gdbstub_user-target.c.olibqemu-aarch64-linux-user.a.p/linux-user_elfload.c.olibqemu-aarch64-linux-user.a.p/linux-user_exit.c.olibqemu-aarch64-linux-user.a.p/linux-user_fd-trans.c.olibqemu-aarch64-linux-user.a.p/linux-user_linuxload.c.olibqemu-aarch64-linux-user.a.p/linux-user_main.c.olibqemu-aarch64-linux-user.a.p/linux-user_mmap.c.olibqemu-aarch64-linux-user.a.p/linux-user_signal.c.olibqemu-aarch64-linux-user.a.p/linux-user_strace.c.olibqemu-aarch64-linux-user.a.p/linux-user_syscall.c.olibqemu-aarch64-linux-user.a.p/linux-user_thunk.c.olibqemu-aarch64-linux-user.a.p/linux-user_uaccess.c.olibqemu-aarch64-linux-user.a.p/linux-user_uname.c.olibqemu-aarch64-linux-user.a.p/linux-user_flatload.c.olibqemu-aarch64-linux-user.a.p/linux-user_semihost.c.olibqemu-aarch64-linux-user.a.p/linux-user_plugin-api.c.olibqemu-aarch64-linux-user.a.p/linux-user_aarch64_mte_user_helper.c.olibhwcore.a.p/hw_core_bus.c.olibhwcore.a.p/hw_core_gpio.c.olibhwcore.a.p/hw_core_qdev-properties.c.olibhwcore.a.p/hw_core_qdev.c.olibhwcore.a.p/hw_core_resetcontainer.c.olibhwcore.a.p/hw_core_resettable.c.olibhwcore.a.p/hw_core_vmstate-if.c.olibhwcore.a.p/hw_core_irq.c.olibhwcore.a.p/hw_core_clock.c.olibhwcore.a.p/hw_core_qdev-clock.c.olibqom.a.p/qom_container.c.olibqom.a.p/qom_object.c.olibqom.a.p/qom_object_interfaces.c.olibqom.a.p/qom_qom-qobject.c.olibqom.a.p/qom_compat-properties.c.olibevent-loop-base.a.p/event-loop-base.c.o-Wl,--as-needed -Wl,--no-undefined -pie -fstack-protector-strong -Wl,-z,relro -Wl,-z,now -Wl,--start-group libqemuutil.a subprojects/libvhost-user/libvhost-user-glib.a subprojects/libvhost-user/libvhost-user.a libstubs_arm.a -Xlinker --dynamic-list=/work/armbru/qemu/bld/plugins/qemu-plugin.symbols/usr/lib64/libcapstone.so/usr/lib64/libz.so/usr/lib64/libdw.so/usr/lib64/libelf.so-lnuma/usr/lib64/liburing.so/usr/lib64/libgio-2.0.so/usr/lib64/libgobject-2.0.so/usr/lib64/libglib-2.0.so/usr/lib64/libgmodule-2.0.so-pthread/usr/lib64/libgnutls.so-lm/usr/lib64/libpixman-1.so/usr/lib64/libepoxy.so-Wl,--end-group/usr/bin/ld:libqemu-aarch64-linux-user.a.p/target_arm_cpu64.c.o: in function `arm_cpu_sve_finalize':
/work/armbru/qemu/bld/../target/arm/cpu64.c:146:(.text+0x11f2): undefined reference to `arm_find_model'/usr/bin/ld:libqemu-aarch64-linux-user.a.p/target_arm_cpu64.c.o: in function `arm_cpu_pauth_finalize':
/work/armbru/qemu/bld/../target/arm/cpu64.c:583:(.text+0x1a55): undefined reference to `arm_find_model'
collect2: error: ld returned 1 exit status
Re: [RFC PATCH v3 16/19] qmp: add query-cpu-props-info command
Quoted 26 lines · Khushit Shah
Quoted 23 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 11 lines · Khushit Shah
Quoted 10 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Series doesn't apply for me. I need to apply it to be able to check rendered documentation. Could you push it somewhere I can pull?
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Sorry for the late reply,
Please use the following branch: https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_khushit-2Dshah-2Dnx_qemu_tree_upstream-2Drfc-2Dv3-2Dfixups&d=DwIFaQ&c=s883GpUCOChKOHiocYtGcg&r=PGWMyignA0NiDmTlyP7vOTHozBws_VN86yrVmSMkBp0&m=jlEKINn7T9VpWSJkWeOuzIpFt5Hs3kXB6PwWQoiRYhHwkovj5haqCBtYIV_Ds1EQ&s=7QmSEQKWrSTCnV-3Crq1zl_IHQGCiY6VpAmFXqbCb9s&e=Doesn't compile for me:
Wow, extremely sorry for this, will take a look.
Stub file was missing on arm user builds.
I have fixed this on the private branch if you want to take a look.
I also understand if you want to wait for proper v4 with the fix.
Again, sorry for this, should have checked all configs before sending the patch.
Quoted 15 lines
Quoted 15 lines
FAILED: [code=1] qemu-aarch64_be
cc -m64 -o qemu-aarch64_belibcommon.a.p/accel_accel-common.c.olibcommon.a.p/hw_core_cpu-common.c.olibcommon.a.p/hw_core_machine-smp.c.olibcommon.a.p/cpu-common.c.olibcommon.a.p/page-vary-common.c.olibcommon.a.p/target-info.c.olibcommon.a.p/disas_capstone.c.olibcommon.a.p/disas_disas-host.c.olibcommon.a.p/disas_disas-target.c.olibcommon.a.p/disas_objdump.c.olibcommon.a.p/disas_disas-common.c.olibcommon.a.p/fpu_softfloat.c.olibcommon.a.p/plugins_loader.c.olibcommon.a.p/meson-generated_.._gdbstub_gdbstub-xml.c.olibcommon_arm.a.p/target_arm_mmuidx.c.olibcommon_arm.a.p/target_arm_tcg_arith_helper.c.olibcommon_arm.a.p/target_arm_tcg_crypto_helper.c.olibuser.a.p/semihosting_user.c.olibuser.a.p/semihosting_guestfd.c.olibuser.a.p/accel_accel-user.c.olibuser.a.p/accel_tcg_cpu-exec.c.olibuser.a.p/accel_tcg_cpu-exec-common.c.olibuser.a.p/accel_tcg_tcg-runtime.c.olibuser.a.p/accel_tcg_tcg-runtime-gvec.c.olibuser.a.p/accel_tcg_tb-maint.c.olibuser.a.p/accel_tcg_tcg-all.c.olibuser.a.p/accel_tcg_tcg-stats.c.olibuser.a.p/accel_tcg_translate-all.c.olibuser.a.p/accel_tcg_translator.c.olibuser.a.p/accel_tcg_plugin-gen.c.olibuser.a.p/accel_tcg_user-exec.c.olibuser.a.p/accel_tcg_user-exec-stub.c.olibuser.a.p/hw_core_cpu-user.c.olibuser.a.p/hw_core_qdev-user.c.olibuser.a.p/gdbstub_gdbstub.c.olibuser.a.p/gdbstub_syscalls.c.olibuser.a.p/gdbstub_user.c.olibuser.a.p/cpu-target.c.olibuser.a.p/tcg_optimize.c.olibuser.a.p/tcg_region.c.olibuser.a.p/tcg_tcg.c.olibuser.a.p/tcg_tcg-common.c.olibuser.a.p/tcg_tcg-op.c.olibuser.a.p/tcg_tcg-op-ldst.c.olibuser.a.p/tcg_tcg-op-gvec.c.olibuser.a.p/tcg_tcg-op-vec.c.olibuser.a.p/tcg_debuginfo.c.olibuser.a.p/tcg_perf.c.olibuser.a.p/plugins_user.c.olibuser.a.p/plugins_api-user.c.olibuser.a.p/plugins_api.c.olibuser.a.p/plugins_core.c.olibuser.a.p/common-user_safe-syscall.S.olibuser.a.p/common-user_safe-syscall-error.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_gdbstub.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_cpu.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_cpregs-gcs.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_cpregs-pmu.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_debug_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_vfp_fpscr.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_el2-stubs.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_cpregs-omap-stub.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_common-semi-target.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_debug.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_gengvec.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_hflags.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_m_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_mve_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_neon_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_op_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_tlb_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate-m-nocp.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate-mve.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate-neon.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate-vfp.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_vec_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_vfp_helper.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_aarch64_cpu_loop.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_aarch64_elfload.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_aarch64_signal.c.olibqemu-aarch64_be-linux-user.a.p/target-info-stub.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_cpu64.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_gdbstub64.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_cpu32.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_cpu64.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_gengvec64.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate-a64.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate-sve.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_translate-sme.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_helper-a64.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_mte_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_pauth_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_sme_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_sve_helper.c.olibqemu-aarch64_be-linux-user.a.p/target_arm_tcg_vec_helper64.c.olibqemu-aarch64_be-linux-user.a.p/semihosting_syscalls.c.olibqemu-aarch64_be-linux-user.a.p/semihosting_arm-compat-semi.c.olibqemu-aarch64_be-linux-user.a.p/accel_accel-target.c.olibqemu-aarch64_be-linux-user.a.p/hw_intc_arm_gicv3_hvf_stub.c.olibqemu-aarch64_be-linux-user.a.p/gdbstub_user-target.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_elfload.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_exit.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_fd-trans.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_linuxload.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_main.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_mmap.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_signal.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_strace.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_syscall.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_thunk.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_uaccess.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_uname.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_flatload.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_semihost.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_plugin-api.c.olibqemu-aarch64_be-linux-user.a.p/linux-user_aarch64_mte_user_helper.c.olibhwcore.a.p/hw_core_bus.c.olibhwcore.a.p/hw_core_gpio.c.olibhwcore.a.p/hw_core_qdev-properties.c.olibhwcore.a.p/hw_core_qdev.c.olibhwcore.a.p/hw_core_resetcontainer.c.olibhwcore.a.p/hw_core_resettable.c.olibhwcore.a.p/hw_core_vmstate-if.c.olibhwcore.a.p/hw_core_irq.c.olibhwcore.a.p/hw_core_clock.c.olibhwcore.a.p/hw_core_qdev-clock.c.olibqom.a.p/qom_container.c.olibqom.a.p/qom_object.c.olibqom.a.p/qom_object_interfaces.c.olibqom.a.p/qom_qom-qobject.c.olibqom.a.p/qom_compat-properties.c.olibevent-loop-base.a.p/event-loop-base.c.o-Wl,--as-needed -Wl,--no-undefined -pie -fstack-protector-strong -Wl,-z,relro -Wl,-z,now -Wl,--start-group libqemuutil.a subprojects/libvhost-user/libvhost-user-glib.a subprojects/libvhost-user/libvhost-user.a libstubs_arm.a -Xlinker --dynamic-list=/work/armbru/qemu/bld/plugins/qemu-plugin.symbols/usr/lib64/libcapstone.so/usr/lib64/libz.so/usr/lib64/libdw.so/usr/lib64/libelf.so-lnuma/usr/lib64/liburing.so/usr/lib64/libgio-2.0.so/usr/lib64/libgobject-2.0.so/usr/lib64/libglib-2.0.so/usr/lib64/libgmodule-2.0.so-pthread/usr/lib64/libgnutls.so-lm/usr/lib64/libpixman-1.so/usr/lib64/libepoxy.so-Wl,--end-group/usr/bin/ld:libqemu-aarch64_be-linux-user.a.p/target_arm_cpu64.c.o: in function `arm_cpu_sve_finalize':
/work/armbru/qemu/bld/../target/arm/cpu64.c:146:(.text+0x11f2): undefined reference to `arm_find_model'/usr/bin/ld:libqemu-aarch64_be-linux-user.a.p/target_arm_cpu64.c.o: in function `arm_cpu_pauth_finalize':
/work/armbru/qemu/bld/../target/arm/cpu64.c:583:(.text+0x1a55): undefined reference to `arm_find_model'
collect2: error: ld returned 1 exit status
[6689/7247] Linking target qemu-aarch64
FAILED: [code=1] qemu-aarch64
cc -m64 -o qemu-aarch64libcommon.a.p/accel_accel-common.c.olibcommon.a.p/hw_core_cpu-common.c.olibcommon.a.p/hw_core_machine-smp.c.olibcommon.a.p/cpu-common.c.olibcommon.a.p/page-vary-common.c.olibcommon.a.p/target-info.c.olibcommon.a.p/disas_capstone.c.olibcommon.a.p/disas_disas-host.c.olibcommon.a.p/disas_disas-target.c.olibcommon.a.p/disas_objdump.c.olibcommon.a.p/disas_disas-common.c.olibcommon.a.p/fpu_softfloat.c.olibcommon.a.p/plugins_loader.c.olibcommon.a.p/meson-generated_.._gdbstub_gdbstub-xml.c.olibcommon_arm.a.p/target_arm_mmuidx.c.olibcommon_arm.a.p/target_arm_tcg_arith_helper.c.olibcommon_arm.a.p/target_arm_tcg_crypto_helper.c.olibuser.a.p/semihosting_user.c.olibuser.a.p/semihosting_guestfd.c.olibuser.a.p/accel_accel-user.c.olibuser.a.p/accel_tcg_cpu-exec.c.olibuser.a.p/accel_tcg_cpu-exec-common.c.olibuser.a.p/accel_tcg_tcg-runtime.c.olibuser.a.p/accel_tcg_tcg-runtime-gvec.c.olibuser.a.p/accel_tcg_tb-maint.c.olibuser.a.p/accel_tcg_tcg-all.c.olibuser.a.p/accel_tcg_tcg-stats.c.olibuser.a.p/accel_tcg_translate-all.c.olibuser.a.p/accel_tcg_translator.c.olibuser.a.p/accel_tcg_plugin-gen.c.olibuser.a.p/accel_tcg_user-exec.c.olibuser.a.p/accel_tcg_user-exec-stub.c.olibuser.a.p/hw_core_cpu-user.c.olibuser.a.p/hw_core_qdev-user.c.olibuser.a.p/gdbstub_gdbstub.c.olibuser.a.p/gdbstub_syscalls.c.olibuser.a.p/gdbstub_user.c.olibuser.a.p/cpu-target.c.olibuser.a.p/tcg_optimize.c.olibuser.a.p/tcg_region.c.olibuser.a.p/tcg_tcg.c.olibuser.a.p/tcg_tcg-common.c.olibuser.a.p/tcg_tcg-op.c.olibuser.a.p/tcg_tcg-op-ldst.c.olibuser.a.p/tcg_tcg-op-gvec.c.olibuser.a.p/tcg_tcg-op-vec.c.olibuser.a.p/tcg_debuginfo.c.olibuser.a.p/tcg_perf.c.olibuser.a.p/plugins_user.c.olibuser.a.p/plugins_api-user.c.olibuser.a.p/plugins_api.c.olibuser.a.p/plugins_core.c.olibuser.a.p/common-user_safe-syscall.S.olibuser.a.p/common-user_safe-syscall-error.c.olibqemu-aarch64-linux-user.a.p/target_arm_gdbstub.c.olibqemu-aarch64-linux-user.a.p/target_arm_cpu.c.olibqemu-aarch64-linux-user.a.p/target_arm_cpregs-gcs.c.olibqemu-aarch64-linux-user.a.p/target_arm_cpregs-pmu.c.olibqemu-aarch64-linux-user.a.p/target_arm_debug_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_vfp_fpscr.c.olibqemu-aarch64-linux-user.a.p/target_arm_el2-stubs.c.olibqemu-aarch64-linux-user.a.p/target_arm_cpregs-omap-stub.c.olibqemu-aarch64-linux-user.a.p/target_arm_common-semi-target.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_debug.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_gengvec.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_hflags.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_m_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_mve_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_neon_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_op_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_tlb_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_translate.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_translate-m-nocp.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_translate-mve.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_translate-neon.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_translate-vfp.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_vec_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_vfp_helper.c.olibqemu-aarch64-linux-user.a.p/linux-user_aarch64_cpu_loop.c.olibqemu-aarch64-linux-user.a.p/linux-user_aarch64_elfload.c.olibqemu-aarch64-linux-user.a.p/linux-user_aarch64_signal.c.olibqemu-aarch64-linux-user.a.p/target-info-stub.c.olibqemu-aarch64-linux-user.a.p/target_arm_cpu64.c.olibqemu-aarch64-linux-user.a.p/target_arm_gdbstub64.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_cpu32.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_cpu64.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_gengvec64.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_translate-a64.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_translate-sve.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_translate-sme.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_helper-a64.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_mte_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_pauth_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_sme_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_sve_helper.c.olibqemu-aarch64-linux-user.a.p/target_arm_tcg_vec_helper64.c.olibqemu-aarch64-linux-user.a.p/semihosting_syscalls.c.olibqemu-aarch64-linux-user.a.p/semihosting_arm-compat-semi.c.olibqemu-aarch64-linux-user.a.p/accel_accel-target.c.olibqemu-aarch64-linux-user.a.p/hw_intc_arm_gicv3_hvf_stub.c.olibqemu-aarch64-linux-user.a.p/gdbstub_user-target.c.olibqemu-aarch64-linux-user.a.p/linux-user_elfload.c.olibqemu-aarch64-linux-user.a.p/linux-user_exit.c.olibqemu-aarch64-linux-user.a.p/linux-user_fd-trans.c.olibqemu-aarch64-linux-user.a.p/linux-user_linuxload.c.olibqemu-aarch64-linux-user.a.p/linux-user_main.c.olibqemu-aarch64-linux-user.a.p/linux-user_mmap.c.olibqemu-aarch64-linux-user.a.p/linux-user_signal.c.olibqemu-aarch64-linux-user.a.p/linux-user_strace.c.olibqemu-aarch64-linux-user.a.p/linux-user_syscall.c.olibqemu-aarch64-linux-user.a.p/linux-user_thunk.c.olibqemu-aarch64-linux-user.a.p/linux-user_uaccess.c.olibqemu-aarch64-linux-user.a.p/linux-user_uname.c.olibqemu-aarch64-linux-user.a.p/linux-user_flatload.c.olibqemu-aarch64-linux-user.a.p/linux-user_semihost.c.olibqemu-aarch64-linux-user.a.p/linux-user_plugin-api.c.olibqemu-aarch64-linux-user.a.p/linux-user_aarch64_mte_user_helper.c.olibhwcore.a.p/hw_core_bus.c.olibhwcore.a.p/hw_core_gpio.c.olibhwcore.a.p/hw_core_qdev-properties.c.olibhwcore.a.p/hw_core_qdev.c.olibhwcore.a.p/hw_core_resetcontainer.c.olibhwcore.a.p/hw_core_resettable.c.olibhwcore.a.p/hw_core_vmstate-if.c.olibhwcore.a.p/hw_core_irq.c.olibhwcore.a.p/hw_core_clock.c.olibhwcore.a.p/hw_core_qdev-clock.c.olibqom.a.p/qom_container.c.olibqom.a.p/qom_object.c.olibqom.a.p/qom_object_interfaces.c.olibqom.a.p/qom_qom-qobject.c.olibqom.a.p/qom_compat-properties.c.olibevent-loop-base.a.p/event-loop-base.c.o-Wl,--as-needed -Wl,--no-undefined -pie -fstack-protector-strong -Wl,-z,relro -Wl,-z,now -Wl,--start-group libqemuutil.a subprojects/libvhost-user/libvhost-user-glib.a subprojects/libvhost-user/libvhost-user.a libstubs_arm.a -Xlinker --dynamic-list=/work/armbru/qemu/bld/plugins/qemu-plugin.symbols/usr/lib64/libcapstone.so/usr/lib64/libz.so/usr/lib64/libdw.so/usr/lib64/libelf.so-lnuma/usr/lib64/liburing.so/usr/lib64/libgio-2.0.so/usr/lib64/libgobject-2.0.so/usr/lib64/libglib-2.0.so/usr/lib64/libgmodule-2.0.so-pthread/usr/lib64/libgnutls.so-lm/usr/lib64/libpixman-1.so/usr/lib64/libepoxy.so-Wl,--end-group/usr/bin/ld:libqemu-aarch64-linux-user.a.p/target_arm_cpu64.c.o: in function `arm_cpu_sve_finalize':
/work/armbru/qemu/bld/../target/arm/cpu64.c:146:(.text+0x11f2): undefined reference to `arm_find_model'/usr/bin/ld:libqemu-aarch64-linux-user.a.p/target_arm_cpu64.c.o: in function `arm_cpu_pauth_finalize':
/work/armbru/qemu/bld/../target/arm/cpu64.c:583:(.text+0x1a55): undefined reference to `arm_find_model'
collect2: error: ld returned 1 exit status
Re: [RFC PATCH v3 16/19] qmp: add query-cpu-props-info command
Khushit Shah <[email protected]> writes:
[...]
Quoted 3 lines
Stub file was missing on arm user builds.
I have fixed this on the private branch if you want to take a look.
I'm willing to pull an update to v3, assuming it's a small fix.
Quoted 1 line
I also understand if you want to wait for proper v4 with the fix.
Eventually.
Quoted 2 lines
Again, sorry for this, should have checked all configs before sending the patch.
Mistakes happen, and then we learn from them :)
[...]
Re: [RFC PATCH v3 16/19] qmp: add query-cpu-props-info command
Quoted 11 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Khushit Shah <[email protected]> writes:
Quoted 7 lines
[...]
Quoted 3 lines
Stub file was missing on arm user builds.
I have fixed this on the private branch if you want to take a look.
I'm willing to pull an update to v3, assuming it's a small fix.
It is a small fix :)
Quoted 9 lines
Quoted 1 line
I also understand if you want to wait for proper v4 with the fix.
Eventually.
Quoted 2 lines
Again, sorry for this, should have checked all configs before sending the patch.
Mistakes happen, and then we learn from them :)
: )
Quoted 2 lines
[...]
Re: [RFC PATCH v3 16/19] qmp: add query-cpu-props-info command
Quoted 11 lines · Khushit Shah
Quoted 11 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Khushit Shah <[email protected]> writes:
[...]
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Stub file was missing on arm user builds.
I have fixed this on the private branch if you want to take a look.
I'm willing to pull an update to v3, assuming it's a small fix.
It is a small fix :)
Please tell me what to pull. When you're ready, of course.
[...]
Re: [RFC PATCH v3 16/19] qmp: add query-cpu-props-info command
Quoted 24 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 13 lines · Khushit Shah
Quoted 13 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Khushit Shah <[email protected]> writes:
[...]
Quoted 2 lines
Stub file was missing on arm user builds.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
I have fixed this on the private branch if you want to take a look.
I'm willing to pull an update to v3, assuming it's a small fix.
It is a small fix :)
Please tell me what to pull. When you're ready, of course.
It’s on the same private branch: https://github.com/khushit-shah-nx/qemu/tree/upstream-rfc-v3-fixups
Re: [RFC PATCH v3 16/19] qmp: add query-cpu-props-info command
Quoted 24 lines · Khushit Shah
Quoted 24 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 15 lines · Khushit Shah
Quoted 15 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Khushit Shah <[email protected]> writes:
[...]
Quoted 3 lines
Stub file was missing on arm user builds.
I have fixed this on the private branch if you want to take a look.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
I'm willing to pull an update to v3, assuming it's a small fix.
It is a small fix :)
Please tell me what to pull. When you're ready, of course.
It’s on the same private branch: https://github.com/khushit-shah-nx/qemu/tree/upstream-rfc-v3-fixups
Builds, but fails "make check" on my box *sigh*.
tests/qtest/qmp-cmd-test.c needs an update.
Re: [RFC PATCH v3 16/19] qmp: add query-cpu-props-info command
Quoted 39 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 28 lines · Khushit Shah
Quoted 28 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 18 lines · Khushit Shah
Quoted 9 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Khushit Shah <[email protected]> writes:
Quoted 7 lines
[...]
Quoted 3 lines
Stub file was missing on arm user builds.
I have fixed this on the private branch if you want to take a look.
I'm willing to pull an update to v3, assuming it's a small fix.
It is a small fix :)
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Please tell me what to pull. When you're ready, of course.
Builds, but fails "make check" on my box *sigh*.
tests/qtest/qmp-cmd-test.cneeds an update.
:’)
Fixed it, available on:
https://github.com/khushit-shah-nx/qemu/tree/upstream-rfc-v3-fixups
On my machine, qemu:qtest+qtest-aarch64 / qtest-aarch64/device-introspect-test still fails. (It will likely not fail for you if you are on (arm + kvm or any other Arch))
I have reported this to Eric as the fail stems from the base "customizable host model” series.
Sorry for the hiccups, and thanks for your patience, will take care from now on.
Re: [RFC PATCH v3 16/19] qmp: add query-cpu-props-info command
Quoted 45 lines · Khushit Shah
Quoted 32 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 22 lines · Khushit Shah
Quoted 22 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 13 lines · Khushit Shah
Quoted 13 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Khushit Shah <[email protected]> writes:
[...]
Quoted 2 lines
Stub file was missing on arm user builds.
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
Quoted 2 lines
Quoted 1 line
I have fixed this on the private branch if you want to take a look.
I'm willing to pull an update to v3, assuming it's a small fix.
It is a small fix :)
Please tell me what to pull. When you're ready, of course.
Builds, but fails "make check" on my box *sigh*.
tests/qtest/qmp-cmd-test.cneeds an update.:’)
Fixed it, available on:
https://github.com/khushit-shah-nx/qemu/tree/upstream-rfc-v3-fixups
Quoted 6 lines
On my machine, qemu:qtest+qtest-aarch64 / qtest-aarch64/device-introspect-test still fails. (It will likely not fail for you if you are on (arm + kvm or any other Arch))
I have reported this to Eric as the fail stems from the base "customizable host model” series.
yes my bad, this will be fixed in v8
Eric
Quoted 5 lines
Sorry for the hiccups, and thanks for your patience, will take care from now on.
Re: [RFC PATCH v3 16/19] qmp: add query-cpu-props-info command
In reply to Khushit ShahQuoted 13 lines · Khushit Shah
Introduce the 'query-cpu-props-info' QMP command. For CPU model properties it reports the type (boolean or number) and the set of values supported under the active accelerator and host.
For numbers the supported values are expressed as a list of inclusive {min, max} ranges; for booleans as the list of allowed true/false values.
The command and its return types (CpuPropertyType, CpuPropertyInfo and friends) are defined in
qapi/machine.jsonrather than an Arm-specific schema, since the concept applies to other targets (e.g. x86, riscv) too. Target that do not implement it return an error.
Quoted 6 lines
The Arm/KVM implementation spins up a scratch "host" vCPU object, walks its QOM properties:
SYSREG_ID-register fields become 'number' properties whose ranges come fromarm_field_get_supported_values(), and the advertised feature toggles become 'boolean' properties.Signed-off-by Khushit Shah <[email protected]>
This explains what the command does and how it's implemented. It's silent on the most important aspect: why do we want the command? What is its intended purpose?
Re: [RFC PATCH v3 16/19] qmp: add query-cpu-props-info command
Quoted 29 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 18 lines · Khushit Shah
Introduce the 'query-cpu-props-info' QMP command. For CPU model properties it reports the type (boolean or number) and the set of values supported under the active accelerator and host.
For numbers the supported values are expressed as a list of inclusive {min, max} ranges; for booleans as the list of allowed true/false values.
The command and its return types (CpuPropertyType, CpuPropertyInfo and friends) are defined in
qapi/machine.jsonrather than an Arm-specific schema, since the concept applies to other targets (e.g. x86, riscv) too. Target that do not implement it return an error.The Arm/KVM implementation spins up a scratch "host" vCPU object, walks its QOM properties:
SYSREG_ID-register fields become 'number' properties whose ranges come fromarm_field_get_supported_values(), and the advertised feature toggles become 'boolean' properties.
Quoted 5 lines
Quoted 1 line
Signed-off-by Khushit Shah <[email protected]>This explains what the command does and how it's implemented. It's silent on the most important aspect: why do we want the command? What is its intended purpose?
Will add something like:
This helps the management stack to discover which values are supported for a given CPU property. This is especially important for non-boolean properties, where knowing that the host has value 'x' does not inherently reveal the full range of valid values supported on the host.
Re: [RFC PATCH v3 16/19] qmp: add query-cpu-props-info command
Quoted 33 lines · Khushit Shah
Quoted 27 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 18 lines · Khushit Shah
Introduce the 'query-cpu-props-info' QMP command. For CPU model properties it reports the type (boolean or number) and the set of values supported under the active accelerator and host.
For numbers the supported values are expressed as a list of inclusive {min, max} ranges; for booleans as the list of allowed true/false values.
The command and its return types (CpuPropertyType, CpuPropertyInfo and friends) are defined in
qapi/machine.jsonrather than an Arm-specific schema, since the concept applies to other targets (e.g. x86, riscv) too. Target that do not implement it return an error.The Arm/KVM implementation spins up a scratch "host" vCPU object, walks its QOM properties:
SYSREG_ID-register fields become 'number' properties whose ranges come fromarm_field_get_supported_values(), and the advertised feature toggles become 'boolean' properties.Quoted 5 lines
Quoted 1 line
Signed-off-by Khushit Shah <[email protected]>This explains what the command does and how it's implemented. It's silent on the most important aspect: why do we want the command? What is its intended purpose?
Quoted 6 lines
Will add something like:
This helps the management stack to discover which values are supported for a given CPU property. This is especially important for non-boolean properties, where knowing that the host has value 'x' does not inherently reveal the full range of valid values supported on the host.
Better. Perhaps throw in an example if you can come up with a simple one.
Re: [RFC PATCH v3 16/19] qmp: add query-cpu-props-info command
Quoted 46 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 35 lines · Khushit Shah
Quoted 27 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 18 lines · Khushit Shah
Introduce the 'query-cpu-props-info' QMP command. For CPU model properties it reports the type (boolean or number) and the set of values supported under the active accelerator and host.
For numbers the supported values are expressed as a list of inclusive {min, max} ranges; for booleans as the list of allowed true/false values.
The command and its return types (CpuPropertyType, CpuPropertyInfo and friends) are defined in
qapi/machine.jsonrather than an Arm-specific schema, since the concept applies to other targets (e.g. x86, riscv) too. Target that do not implement it return an error.The Arm/KVM implementation spins up a scratch "host" vCPU object, walks its QOM properties:
SYSREG_ID-register fields become 'number' properties whose ranges come fromarm_field_get_supported_values(), and the advertised feature toggles become 'boolean' properties.Quoted 5 lines
Quoted 1 line
Signed-off-by Khushit Shah <[email protected]>This explains what the command does and how it's implemented. It's silent on the most important aspect: why do we want the command? What is its intended purpose?
Will add something like:
Quoted 7 lines
Quoted 4 lines
This helps the management stack to discover which values are supported for a given CPU property. This is especially important for non-boolean properties, where knowing that the host has value 'x' does not inherently reveal the full range of valid values supported on the host.
Better. Perhaps throw in an example if you can come up with a simple one.
Noted
Re: [RFC PATCH v3 16/19] qmp: add query-cpu-props-info command
In reply to Khushit ShahHi Khushit,
Quoted 32 lines · Khushit Shah
Quoted 28 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 18 lines · Khushit Shah
Introduce the 'query-cpu-props-info' QMP command. For CPU model properties it reports the type (boolean or number) and the set of values supported under the active accelerator and host.
For numbers the supported values are expressed as a list of inclusive {min, max} ranges; for booleans as the list of allowed true/false values.
The command and its return types (CpuPropertyType, CpuPropertyInfo and friends) are defined in
qapi/machine.jsonrather than an Arm-specific schema, since the concept applies to other targets (e.g. x86, riscv) too. Target that do not implement it return an error.The Arm/KVM implementation spins up a scratch "host" vCPU object, walks its QOM properties:
SYSREG_ID-register fields become 'number' properties whose ranges come fromarm_field_get_supported_values(), and the advertised feature toggles become 'boolean' properties.Quoted 4 lines
Quoted 1 line
Signed-off-by Khushit Shah <[email protected]>This explains what the command does and how it's implemented. It's silent on the most important aspect: why do we want the command? What is its intended purpose?
Quoted 6 lines
Will add something like:
This helps the management stack to discover which values are supported for a given CPU property. This is especially important for non-boolean properties, where knowing that the host has value 'x' does not inherently reveal the full range of valid values supported on the host.
How does x86 handle this at the moment, they don't have the cmd either? How do they currently introspect what are the valid values for a specific host? Is it easier for them?
Thanks
Eric
Quoted 3 lines
Re: [RFC PATCH v3 16/19] qmp: add query-cpu-props-info command
Quoted 46 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Hi Khushit,
Quoted 34 lines · Khushit Shah
Quoted 28 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 18 lines · Khushit Shah
Introduce the 'query-cpu-props-info' QMP command. For CPU model properties it reports the type (boolean or number) and the set of values supported under the active accelerator and host.
For numbers the supported values are expressed as a list of inclusive {min, max} ranges; for booleans as the list of allowed true/false values.
The command and its return types (CpuPropertyType, CpuPropertyInfo and friends) are defined in
qapi/machine.jsonrather than an Arm-specific schema, since the concept applies to other targets (e.g. x86, riscv) too. Target that do not implement it return an error.The Arm/KVM implementation spins up a scratch "host" vCPU object, walks its QOM properties:
SYSREG_ID-register fields become 'number' properties whose ranges come fromarm_field_get_supported_values(), and the advertised feature toggles become 'boolean' properties.Quoted 4 lines
Quoted 1 line
Signed-off-by Khushit Shah <[email protected]>This explains what the command does and how it's implemented. It's silent on the most important aspect: why do we want the command? What is its intended purpose?
Will add something like:
Quoted 8 lines
Quoted 4 lines
This helps the management stack to discover which values are supported for a given CPU property. This is especially important for non-boolean properties, where knowing that the host has value 'x' does not inherently reveal the full range of valid values supported on the host.
How does x86 handle this at the moment, they don't have the cmd either? How do they currently introspect what are the valid values for a specific host? Is it easier for them?
x86 is much simpler, all the cpu features properties are backed by cpuid bits and assumption is simple, if host value is “true”, “false" is supported, and if the host value is “false", “true" is not supported.
Warm Regards,
Khushit
Quoted 9 lines
Thanks
Eric
Quoted 3 lines
Re: [RFC PATCH v3 16/19] qmp: add query-cpu-props-info command
Quoted 48 lines · Khushit Shah
Quoted 48 lines · Eric Auger
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Hi Khushit,
Quoted 37 lines · Khushit Shah
Quoted 27 lines · Markus Armbruster
!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 18 lines · Khushit Shah
Introduce the 'query-cpu-props-info' QMP command. For CPU model properties it reports the type (boolean or number) and the set of values supported under the active accelerator and host.
For numbers the supported values are expressed as a list of inclusive {min, max} ranges; for booleans as the list of allowed true/false values.
The command and its return types (CpuPropertyType, CpuPropertyInfo and friends) are defined in
qapi/machine.jsonrather than an Arm-specific schema, since the concept applies to other targets (e.g. x86, riscv) too. Target that do not implement it return an error.The Arm/KVM implementation spins up a scratch "host" vCPU object, walks its QOM properties:
SYSREG_ID-register fields become 'number' properties whose ranges come fromarm_field_get_supported_values(), and the advertised feature toggles become 'boolean' properties.Quoted 4 lines
Quoted 1 line
Signed-off-by Khushit Shah <[email protected]>This explains what the command does and how it's implemented. It's silent on the most important aspect: why do we want the command? What is its intended purpose?
Will add something like:
This helps the management stack to discover which values are supported for a given CPU property. This is especially important for non-boolean properties, where knowing that the host has value 'x' does not inherently reveal the full range of valid values supported on the host.
Quoted 6 lines
Quoted 3 lines
How does x86 handle this at the moment, they don't have the cmd either? How do they currently introspect what are the valid values for a specific host? Is it easier for them?
x86 is much simpler, all the cpu features properties are backed by cpuid bits and assumption is simple, if host value is “true”, “false" is supported, and if the host value is “false", “true" is not supported.
OK thanks!
Eric
Quoted 9 lines
Warm Regards,
KhushitQuoted 6 lines
Thanks
Eric
Quoted 2 lines
RFC PATCH v3 17/19 target/arm: Report 0 as supported for ID fields gated by vCPU init flags
In reply to Khushit ShahWhen QEMU queries supported CPU properties via KVM, it uses a scratch vCPU initialized with all host-supported features (like SVE and PAuth).
KVM exposes the corresponding ID register fields (e.g., ID_AA64ISAR1_EL1.APA) as read-only, the supported values only shows the enabled host value (e.g., 5) and omits 0. This will lead into falsely flagging a model as blocked as the features can be masked by not passing those flags. For these fields, even if KVM reports them as non-writable, we explicitly append "0" to the list of supported values if the host value is non-zero.
--- target/arm/kvm.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
target/arm/kvm.c +25 -0
@@ -1292,6 +1292,24 @@ static void ranges_add(GArray *ranges, uint64_t min, uint64_t max)g_array_append_val (ranges, r); } +/* +* Some fields are reported as non-writable by KVM but can still be +* disabled by not requesting the corresponding vCPU init feature flag +* (SVE, pauth). The supported values are derived from a scratch vCPU +* whose init flags may differ from the real vCPU, so for these fields +* "off" (0) is a supported value in addition to the host value. +*/ +static bool arm_field_off_via_vcpu_flags (const ARM64SysRegField *field) +{ +return field_matches (field,ID_AA64PFR0_EL1_IDX ,"SVE" ) || +field_matches (field,ID_AA64ISAR1_EL1_IDX ,"APA" ) || +field_matches (field,ID_AA64ISAR1_EL1_IDX ,"API" ) || +field_matches (field,ID_AA64ISAR1_EL1_IDX ,"GPA" ) || +field_matches (field,ID_AA64ISAR1_EL1_IDX ,"GPI" ) || +field_matches (field,ID_AA64ISAR2_EL1_IDX ,"APA3" ) || +field_matches (field,ID_AA64ISAR2_EL1_IDX ,"GPA3" ); +} +void arm_field_get_supported_values (const ARM64SysRegField *field,const ARMISARegisters *host_isar,ArmFieldValueSet **value_set)
@@ -1304,6 +1322,13 @@ void arm_field_get_supported_values(const ARM64SysRegField *field,/* A non-writable field can only ever hold the host value. */ if (!arm_field_is_writable (field)) {ranges_add (ranges, host, host); +/* +* ...unless it is one of the fields that can still be turned off +* via vCPU init flags, in which case "off" (0) is also supported. +*/ +if (host !=0 &&arm_field_off_via_vcpu_flags (field)) { +ranges_add (ranges,0 ,0 ); + } goto done; }
Signature · 1 line
2.52.0
RFC PATCH v3 18/19 target/arm/qmp: hook blockers in query-cpu-definitions
In reply to Khushit ShahNow, report blocker for named cpu models in query-cpu-definitions. Heavy handling is done by validating the realized ID registers values against the host values. sveNNNN needs special handling as those are not stored in any ID registers.
Introduces arm_cpu_class_check_missing_features() and aarch64_idregs_get_blockers() to achieve this. This way we need not instantiate each model to check if it can be realized and we also get granular information on the ID reg fields blocking the realization.
--- target/arm/arm-cpu-models-stub.c | 5 ++++ target/arm/arm-cpu-models.c | 35 ++++++++++++++++++++++ target/arm/arm-cpu-models.h | 2 ++ target/arm/arm-qmp-cmds.c | 12 ++++++++ target/arm/cpu64.c | 51 ++++++++++++++++++++++++++++++++ target/arm/internals.h | 3 ++ target/arm/kvm-stub.c | 10 +++++++ target/arm/kvm.c | 4 +-- target/arm/kvm_arm.h | 17 +++++++++++ 9 files changed, 137 insertions(+), 2 deletions(-)
target/arm/arm-cpu-models-stub.c +5 -0
@@ -11,3 +11,8 @@ const ArmNamedCpuModel *arm_find_model(const char *name) {return NULL ; } + +void arm_cpu_class_check_missing_features (ARMCPUClass *acc,strList **blockers) +{ +return ; +}
target/arm/arm-cpu-models.c +35 -0
@@ -475,6 +475,41 @@ static void arm_named_cpu_initfn(Object *obj)arm_realize_model_chain (obj, model, &error_abort); } +void arm_cpu_class_check_missing_features (ARMCPUClass *acc,strList **blockers) +{ +Error *err =NULL ; +Object *obj =object_new_with_class (OBJECT_CLASS (acc)); +ARMCPU *cpu =ARM_CPU (obj); + +if (!kvm_enabled () || !arm_find_model (acc->info->name)) { + goto out; + } + +if (cpu_isar_feature (aa64_sve, cpu)) { +arm_cpu_sve_finalize (cpu, &err); +if (err) { +error_free (err); + err =NULL ; +uint32_t host_vq_map = cpu->sve_vq.supported; +uint32_t model_vq_map = cpu->sve_vq.map; + +if ((model_vq_map & host_vq_map) != model_vq_map) { +for (int vq =1 ; vq <=ARM_MAX_VQ ; vq++) { +uint32_t vq_bit = (1 << (vq -1 )); +if ((model_vq_map & vq_bit) && !(host_vq_map & vq_bit)) { +QAPI_LIST_PREPEND (*blockers, +g_strdup_printf ("sve%d" , vq *128 )); + } + } + } + } + } + +aarch64_idregs_get_blockers (cpu,kvm_arm_get_host_isar (), blockers); +out: +object_unref (obj); +} +void arm_register_named_cpu_models (void ) {size_t i;
target/arm/arm-cpu-models.h +2 -0
@@ -7,6 +7,7 @@#include "qapi/error.h" #include "qom/object.h" +#include "cpu.h" typedef enum ArmModelPropType { ARM_MODEL_PROP_BOOL,
@@ -31,5 +32,6 @@ typedef struct ArmNamedCpuModel {void arm_register_named_cpu_models (void );const ArmNamedCpuModel *arm_find_model (const char *name); +void arm_cpu_class_check_missing_features (ARMCPUClass *acc,strList **blockers);#endif /* ARM_CPU_MODELS_H */
target/arm/arm-qmp-cmds.c +12 -0
@@ -341,6 +341,18 @@ static void arm_cpu_add_definition(gpointer data, gpointer user_data) info->name =cpu_model_from_type (typename); info->q_typename =g_strdup (typename); +/* calculate blockers */ +if (kvm_enabled () + && !g_str_equal (info->name,"host" ) + && !g_str_equal (info->name,"max" ) + &&arm_find_model (info->name) !=NULL ) { +arm_cpu_class_check_missing_features (ARM_CPU_CLASS (oc), + &info->unavailable_features); +if (info->unavailable_features) { + info->has_unavailable_features = true; + } + } +QAPI_LIST_PREPEND (*cpu_list, info); }
target/arm/cpu64.c +51 -0
63 lines not on this page · raw message
target/arm/internals.h +3 -0
@@ -1756,6 +1756,9 @@ void aarch64_add_sve_properties(Object *obj);void aarch64_add_sme_properties (Object *obj);#ifndef CONFIG_USER_ONLY void aarch64_add_idregs_properties (Object *obj); +void aarch64_idregs_get_blockers (ARMCPU *cpu, +const ARMISARegisters *host_isar, +strList **blockers);#endif /* Return true if the gdbstub is presenting an AArch64 CPU */
target/arm/kvm-stub.c +10 -0
@@ -131,3 +131,13 @@ void arm_field_get_supported_values(const ARM64SysRegField *field, {g_assert_not_reached (); } + +bool arm_field_skip_writeback_always (const ARM64SysRegField *field) +{ +g_assert_not_reached (); +} + +bool arm_field_skip_writeback_if_not_writable (const ARM64SysRegField *field) +{ +g_assert_not_reached (); +}
target/arm/kvm.c +2 -2
@@ -1394,7 +1394,7 @@ done: (*value_set)->ranges = (ArmFieldRange *)g_array_free (ranges, false); } -static bool arm_field_skip_writeback_always (const ARM64SysRegField *field) +bool arm_field_skip_writeback_always (const ARM64SysRegField *field) {/* * GIC is controlled by the gic-version property and fabricated by KVM
@@ -1412,7 +1412,7 @@ static bool arm_field_skip_writeback_always(const ARM64SysRegField *field) || field->index == CLIDR_EL1_IDX; } -static bool arm_field_skip_writeback_if_not_writable (const ARM64SysRegField *field) +bool arm_field_skip_writeback_if_not_writable (const ARM64SysRegField *field) {/* * KVM populates ID_DFR0_EL1.PerfMon even for AArch64-only guests but
target/arm/kvm_arm.h +17 -0
@@ -172,6 +172,23 @@ void arm_field_get_supported_values(const ARM64SysRegField *field,const ARMISARegisters *host_isar, ArmFieldValueSet **value_set); +/** +* arm_field_skip_writeback_always: +* @field: the ID-register field to test +* +* Returns: true if @field must never be written back to KVM (and so may +* legitimately differ from the host value). +*/ +bool arm_field_skip_writeback_always (const ARM64SysRegField *field); + +/** +* arm_field_skip_writeback_if_not_writable: +* @field: the ID-register field to test +* +* Returns: true if @field should be skipped when it is not writable. +*/ +bool arm_field_skip_writeback_if_not_writable (const ARM64SysRegField *field); +/** * kvm_arm_steal_time_finalize: * @cpu: ARMCPU for which to finalize kvm-steal-time
Signature · 1 line
2.52.0
RFC PATCH v3 19/19 target/arm/kvm: fix host model writeback when kernel supports EL2
In reply to Khushit Shahkvm_arm_get_host_cpu_features() probes the host by spinning up a scratch vCPU and reading its ID registers. When the host kernel advertises nested virtualization, the scratch is created with KVM_ARM_VCPU_HAS_EL2, which makes the kernel run limit_nv_id_reg() on that vCPU and force several fields (e.g. ID_AA64MMFR4_EL1.NV_frac, parts of ID_AA64DFR0_EL1) to values that match KVM's nested-virt capabilities rather than the raw host.
If the actual vCPU is later created without EL2 (e.g. -machine virt,virtualization=off), the EL2-on values cached above no longer match what the kernel exposes for the real vCPU and ID-register writeback fails.
Fix this by caching two host views, one probed with EL2 and one without, and selecting the appropriate view at every use site. For -cpu host (and -cpu max) without EL2 we additionally rebase cpu->isar.idregs[] from the EL2-on view it was initialized with onto the EL2-off view via kvm_arm_rebase_host_idregs(), so each field that the user has not explicitly touched picks up the value that the real vCPU will actually see.
Corner case: the rebase compares the post-init field value against the EL2-on host value to decide whether the user set it. If the user directly or indirectly set field X=i and the EL2-on view also reports feat_X=i but the EL2-off view reports feat_X=j, the rebase cannot distinguish "user asked for i" from "inherited i from host" and will overwrite with j. This only affects -cpu host/max without EL2 on NV enabled kernels where the user-requested value happens to match the EL2-on host view, so we avoid the complexity of user set values tracking and accept the loss here.
Named models are not affected with the issue as they already start with default-zeroed view.
--- target/arm/arm-cpu-models.c | 14 +++++- target/arm/arm-qmp-cmds.c | 2 +- target/arm/cpu64.c | 2 +- target/arm/kvm-stub.c | 4 +- target/arm/kvm.c | 93 ++++++++++++++++++++++++++++++------- target/arm/kvm_arm.h | 5 +- 6 files changed, 94 insertions(+), 26 deletions(-)
target/arm/arm-cpu-models.c +12 -2
@@ -459,7 +459,12 @@ static void arm_named_cpu_initfn(Object *obj)return ; } -kvm_arm_set_cpu_features_from_host (cpu); +/* +* Start with the host view without EL2. +* If nested virt is needed user must provide values for all the +* blockers. +*/ +kvm_arm_set_cpu_features_from_host (cpu, false);if (!arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) {return ; }
@@ -481,10 +486,15 @@ void arm_cpu_class_check_missing_features(ARMCPUClass *acc, strList **blockers)Object *obj =object_new_with_class (OBJECT_CLASS (acc));ARMCPU *cpu =ARM_CPU (obj); +const ARMISARegisters *host_isar; +if (!kvm_enabled () || !arm_find_model (acc->info->name)) { goto out; } +/* Use the host view without EL2 to calculate blockers. */ + host_isar =kvm_arm_get_host_isar (false); +if (cpu_isar_feature (aa64_sve, cpu)) {arm_cpu_sve_finalize (cpu, &err);if (err) {
@@ -505,7 +515,7 @@ void arm_cpu_class_check_missing_features(ARMCPUClass *acc, strList **blockers) } } -aarch64_idregs_get_blockers (cpu,kvm_arm_get_host_isar (), blockers); +aarch64_idregs_get_blockers (cpu, host_isar, blockers); out:object_unref (obj); }
target/arm/arm-qmp-cmds.c +1 -1
@@ -102,7 +102,7 @@ CpuPropertyInfoList *qmp_query_cpu_props_info(Error **errp)return NULL ; } - host_isar =kvm_arm_get_host_isar (); + host_isar =kvm_arm_get_host_isar (false);/* * Spin up a scratch "host" vCPU object and walk its QOM properties.
target/arm/cpu64.c +1 -1
@@ -1050,7 +1050,7 @@ static void aarch64_host_initfn(Object *obj)#if defined(CONFIG_KVM )kvm_arm_set_cpreg_mig_tolerances (cpu); -kvm_arm_set_cpu_features_from_host (cpu); +kvm_arm_set_cpu_features_from_host (cpu, true);aarch64_add_sve_properties (obj);#ifndef CONFIG_USER_ONLY
target/arm/kvm-stub.c +2 -2
@@ -45,7 +45,7 @@ bool kvm_arm_el2_supported(void)/* * These functions should never actually be called without KVM support. */ -void kvm_arm_set_cpu_features_from_host (ARMCPU *cpu) +void kvm_arm_set_cpu_features_from_host (ARMCPU *cpu,bool with_el2) {g_assert_not_reached (); }
@@ -120,7 +120,7 @@ char *kvm_print_register_name(uint64_t regidx)g_assert_not_reached (); } -const ARMISARegisters *kvm_arm_get_host_isar (void ) +const ARMISARegisters *kvm_arm_get_host_isar (bool with_el2) {return NULL ; }
target/arm/kvm.c +75 -18
170 lines not on this page · raw message
target/arm/kvm_arm.h +3 -2
@@ -129,11 +129,12 @@ void kvm_arm_destroy_scratch_host_vcpu(int *fdarray);/** * kvm_arm_set_cpu_features_from_host: * @cpu: ARMCPU to set the features for +* @with_el2: probe the host with the EL2-enabled scratch vCPU view * * Set up the ARMCPU struct fields up to match the information probed * from the host CPU. */ -void kvm_arm_set_cpu_features_from_host (ARMCPU *cpu); +void kvm_arm_set_cpu_features_from_host (ARMCPU *cpu,bool with_el2);/** * kvm_arm_add_vcpu_properties:
@@ -276,7 +277,7 @@ void kvm_arm_enable_mte(Object *cpuobj, Error **errp);void arm_cpu_kvm_set_irq (void *arm_cpu,int irq,int level); -const ARMISARegisters *kvm_arm_get_host_isar (void ); +const ARMISARegisters *kvm_arm_get_host_isar (bool with_el2);void arm_gic_cap_kvm_probe (GICCapability *v2,GICCapability *v3);
Signature · 1 line
2.52.0