On 28/2/26 23:08, Mohamed Mediouni wrote:
When starting up the VM at EL2, more sysregs are available. Sync the state of 
those.

In addition, sync the state of the EL1 physical timer when the vGIC is used, 
even
if running at EL1. However, no OS running at EL1 is expected to use those 
registers.

Signed-off-by: Mohamed Mediouni <[email protected]>
---
  target/arm/hvf/hvf.c        | 37 ++++++++++++++++++++++++++----
  target/arm/hvf/sysreg.c.inc | 45 +++++++++++++++++++++++++++++++++++++
  2 files changed, 78 insertions(+), 4 deletions(-)


+#define DEF_SYSREG(HVF_ID, op0, op1, crn, crm, op2)  {HVF_ID},
+#define DEF_SYSREG_EL2(HVF_ID, op0, op1, crn, crm, op2)  {HVF_ID, .el2 = true},
+#define DEF_SYSREG_VGIC(HVF_ID, op0, op1, crn, crm, op2)  {HVF_ID, .vgic = 
true},
+#define DEF_SYSREG_VGIC_EL2(HVF_ID, op0, op1, crn, crm, op2)  {HVF_ID, true, 
true},
+
+struct hvf_sreg {
+    hv_sys_reg_t sreg;
+    bool vgic;
+    bool el2;
+};
-#define DEF_SYSREG(HVF_ID, op0, op1, crn, crm, op2) HVF_ID,
-
-static const hv_sys_reg_t hvf_sreg_list[] = {
+static struct hvf_sreg hvf_sreg_list[] = {
  #include "sysreg.c.inc"
  };
@@ -1052,11 +1073,19 @@ int hvf_arch_init_vcpu(CPUState *cpu) /* Populate cp list for all known sysregs */
      for (i = 0; i < sregs_match_len; i++) {
-        hv_sys_reg_t hvf_id = hvf_sreg_list[i];
+        hv_sys_reg_t hvf_id = hvf_sreg_list[i].sreg;
          uint64_t kvm_id = HVF_TO_KVMID(hvf_id);
          uint32_t key = kvm_to_cpreg_id(kvm_id);
          const ARMCPRegInfo *ri = get_arm_cp_reginfo(arm_cpu->cp_regs, key);
+ if (hvf_sreg_list[i].vgic && !hvf_irqchip_in_kernel()) {
+            continue;
+        }
+
+        if (hvf_sreg_list[i].el2 && !hvf_nested_virt_enabled()) {
+            continue;
+        }
Nice :)

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>


Reply via email to