Re: [RFCv2 PATCH 07/12] KVM: SVM: Introduce helper function kvm_get_apic_id

From: Suravee Suthikulpanit
Date: Tue Apr 05 2022 - 17:28:04 EST


Maxim

On 4/5/22 10:58 AM, Suravee Suthikulpanit wrote:



      avic_invalidate_logical_id_entry(vcpu);
      if (ldr)
@@ -464,7 +471,12 @@ static int avic_handle_apic_id_update(struct kvm_vcpu *vcpu)
  {
      u64 *old, *new;
      struct vcpu_svm *svm = to_svm(vcpu);
-    u32 id = kvm_xapic_id(vcpu->arch.apic);
+    u32 id;
+    int ret;
+
+    ret = kvm_get_apic_id(vcpu, &id);
+    if (ret)
+        return 1;

Well this function is totally broken anyway and I woudn't even bother touching it,
maximum, just stick 'return 0' in the very start of this function if the apic is
in x2apic mode now.

Oh well...


Sorry, I'm not sure if I understand what you mean by "broken".

This function setup/update the AVIC physical APIC ID table, whenever the APIC ID is
initialize or updated. It is needed in both xAPIC and x2APIC cases.

Actually, I will rework this part and send out change in the next revision.

Thanks,
Suravee