Re: [PATCH v6 34/60] i386/tdx: implement tdx_cpu_realizefn()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/5/24 07:23, Xiaoyao Li wrote:
+static void tdx_cpu_realizefn(X86ConfidentialGuest *cg, CPUState *cs,
+                              Error **errp)
+{
+    X86CPU *cpu = X86_CPU(cs);
+    uint32_t host_phys_bits = host_cpu_phys_bits();
+
+    if (!cpu->phys_bits) {
+        cpu->phys_bits = host_phys_bits;
+    } else if (cpu->phys_bits != host_phys_bits) {
+        error_setg(errp, "TDX only supports host physical bits (%u)",
+                   host_phys_bits);
+    }
+}

This should be already handled by host_cpu_realizefn(), which is reached via cpu_exec_realizefn().

Why is it needed earlier, but not as early as instance_init? If absolutely needed I would do the assignment in patch 33, but I don't understand why it's necessary.

Either way, the check should be in tdx_check_features.

Paolo

  static int tdx_validate_attributes(TdxGuest *tdx, Error **errp)
  {
      if ((tdx->attributes & ~tdx_caps->supported_attrs)) {
@@ -733,4 +749,5 @@ static void tdx_guest_class_init(ObjectClass *oc, void *data)
      klass->kvm_init = tdx_kvm_init;
      x86_klass->kvm_type = tdx_kvm_type;
      x86_klass->cpu_instance_init = tdx_cpu_instance_init;
+    x86_klass->cpu_realizefn = tdx_cpu_realizefn;
  }





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux