Re: [PART1 V5 07/13] KVM: x86: Detect and Initialize AVIC support
From: Borislav Petkov
Date: Tue May 10 2016 - 05:14:57 EST
On Wed, May 04, 2016 at 02:09:46PM -0500, Suravee Suthikulpanit wrote:
> This patch introduces AVIC-related data structure, and AVIC
> initialization code.
>
> There are three main data structures for AVIC:
> * Virtual APIC (vAPIC) backing page (per-VCPU)
> * Physical APIC ID table (per-VM)
> * Logical APIC ID table (per-VM)
>
> Currently, AVIC is disabled by default. Users can manually
> enable AVIC via kernel boot option kvm-amd.avic=1 or during
> kvm-amd module loading with parameter avic=1.
>
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@xxxxxxx>
> ---
> arch/x86/include/asm/kvm_host.h | 4 +
> arch/x86/include/asm/svm.h | 3 +
> arch/x86/kvm/svm.c | 224 +++++++++++++++++++++++++++++++++++++++-
> 3 files changed, 230 insertions(+), 1 deletion(-)
...
> @@ -162,8 +173,19 @@ struct vcpu_svm {
>
> /* cached guest cpuid flags for faster access */
> bool nrips_enabled : 1;
> +
> + struct page *avic_backing_page;
> + u64 *avic_physical_id_cache;
> };
>
> +#define AVIC_LOGICAL_ID_ENTRY_GUEST_PHYSICAL_ID_MASK (0xFF)
> +#define AVIC_LOGICAL_ID_ENTRY_VALID_MASK (1 << 31)
> +
> +#define AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK (0xFFULL)
> +#define AVIC_PHYSICAL_ID_ENTRY_BACKING_PAGE_MASK (0xFFFFFFFFFFULL << 12)
> +#define AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK (1ULL << 62)
> +#define AVIC_PHYSICAL_ID_ENTRY_VALID_MASK (1ULL << 63)
Those defines could be shortened a little. Maybe
#define AVIC_PHYSID_HOST_PHYS_MASK
#define AVIC_PHYSID_BACKING_PG_MASK
and so on...
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.