Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1354489

Re: [PART1 RFC v2 10/10] svm: Manage vcpu load/unload when enable AVIC

From Radim Krčmář <rkrcmar@redhat.com>
Newsgroups linux.kernel
Subject Re: [PART1 RFC v2 10/10] svm: Manage vcpu load/unload when enable AVIC
Date 2016-03-09 22:50 +0100
Message-ID <raU9s-5u8-5@gated-at.bofh.it> (permalink)
References <r94PD-3Vt-3@gated-at.bofh.it> <r94PD-3Vt-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


2016-03-04 14:46-0600, Suravee Suthikulpanit:
> From: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> 
> When a vcpu is loaded/unloaded to a physical core, we need to update
> information in the Physical APIC-ID table accordingly.
> 
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> ---
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> @@ -1508,6 +1510,146 @@ static int avic_vcpu_init(struct kvm *kvm, struct vcpu_svm *svm, int id)
> +static inline int
> +avic_update_iommu(struct kvm_vcpu *vcpu, int cpu, phys_addr_t pa, bool r)
> +{
> +	if (!kvm_arch_has_assigned_device(vcpu->kvm))
> +		return 0;
> +
> +	/* TODO: We will hook up with IOMMU API at later time */

(It'd be best to drop avic_update_iommu from this series and introduce
 it when merging iommu support.)

> +	return 0;
> +}
> +
> +static int avic_vcpu_load(struct kvm_vcpu *vcpu, int cpu, bool is_load)

This function does a lot and there is only one thing that must be done
in svm_vcpu_load:  change host physical APIC ID if the CPU changed.
The rest can be done elsewhere:
 - is_running when blocking.
 - kb_pg_ptr when the pointer changes = only on initialization?
 - valid when the kb_pg_ptr is valid = always for existing VCPUs?

> +static int avic_set_running(struct kvm_vcpu *vcpu, bool is_run)

avic_set_running should get address of the entry and write is_run to it.
(No need to touch avic_bk_page, h_phy_apic_id or do bound checks.)

I think you can cache the physical apic id table entry in *vcpu, so both
functions are going to be very simple.

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PART1 RFC v2 10/10] svm: Manage vcpu load/unload when enable AVIC Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com> - 2016-03-04 21:50 +0100
  Re: [PART1 RFC v2 10/10] svm: Manage vcpu load/unload when enable  AVIC Radim Krčmář <rkrcmar@redhat.com> - 2016-03-09 22:50 +0100
    Re: [PART1 RFC v2 10/10] svm: Manage vcpu load/unload when enable  AVIC Radim Krčmář <rkrcmar@redhat.com> - 2016-03-10 15:10 +0100
      Re: [PART1 RFC v2 10/10] svm: Manage vcpu load/unload when enable  AVIC Radim Krčmář <rkrcmar@redhat.com> - 2016-03-14 18:00 +0100
    Re: [PART1 RFC v2 10/10] svm: Manage vcpu load/unload when enable  AVIC Radim Krčmář <rkrcmar@redhat.com> - 2016-03-14 17:50 +0100

csiph-web