mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, x86@kernel.org
Cc: mlevitsk@redhat.com, seanjc@google.com, pbonzini@redhat.com,
	joro@8bytes.org, tglx@linutronix.de, mingo@redhat.com,
	bp@alien8.de, peterz@infradead.org, hpa@zytor.com,
	jon.grimm@amd.com, wei.huang2@amd.com, terry.bowman@amd.com
Subject: Re: [PATCH 07/12] KVM: SVM: Adding support for configuring x2APIC MSRs interception
Date: Thu, 7 Apr 2022 09:44:44 +0700	[thread overview]
Message-ID: <dac4d609-98a3-0311-4234-1e6ba4644cb0@amd.com> (raw)
In-Reply-To: <20220405230855.15376-8-suravee.suthikulpanit@amd.com>



On 4/6/22 6:08 AM, Suravee Suthikulpanit wrote:
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index bbdc16c4b6d7..56ad9ba05111 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -89,7 +89,7 @@ static uint64_t osvw_len = 4, osvw_status;
>   static DEFINE_PER_CPU(u64, current_tsc_ratio);
>   #define TSC_RATIO_DEFAULT	0x0100000000ULL
>   
> -static const struct svm_direct_access_msrs {
> +static struct svm_direct_access_msrs {
>   	u32 index;   /* Index of the MSR */
>   	bool always; /* True if intercept is initially cleared */
>   } direct_access_msrs[MAX_DIRECT_ACCESS_MSRS] = {
> @@ -786,6 +786,33 @@ static void add_msr_offset(u32 offset)
>   	BUG();
>   }
>   
> +static void init_direct_access_msrs(void)
> +{
> +	int i, j;
> +
> +	/* Find first MSR_INVALID */
> +	for (i = 0; i < MAX_DIRECT_ACCESS_MSRS; i++) {
> +		if (direct_access_msrs[i].index == MSR_INVALID)
> +			break;
> +	}
> +	BUG_ON(i >= MAX_DIRECT_ACCESS_MSRS);
> +
> +	/*
> +	 * Initialize direct_access_msrs entries to intercept X2APIC MSRs
> +	 * (range 0x800 to 0x8ff)
> +	 */
> +	for (j = 0; j < 0x100; j++) {
> +		direct_access_msrs[i + j].index = boot_cpu_has(X86_FEATURE_X2AVIC) ?
> +						  (APIC_BASE_MSR + j) : MSR_INVALID;

I found a bug in this part, when testing on system w/o support for x2AVIC feature.

The following change fixes the issue.

-               direct_access_msrs[i + j].index = boot_cpu_has(X86_FEATURE_X2AVIC) ?
-                                                 (APIC_BASE_MSR + j) : MSR_INVALID;
+               direct_access_msrs[i + j].index = (APIC_BASE_MSR + j);

I will update this in V2.

Regards,
Suravee

  reply	other threads:[~2022-04-07  2:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-05 23:08 [PATCH 00/12] Introducing AMD x2APIC Virtualization (x2AVIC) support Suravee Suthikulpanit
2022-04-05 23:08 ` [PATCH 01/12] x86/cpufeatures: Introduce x2AVIC CPUID bit Suravee Suthikulpanit
2022-04-05 23:08 ` [PATCH 02/12] KVM: x86: lapic: Rename [GET/SET]_APIC_DEST_FIELD to [GET/SET]_XAPIC_DEST_FIELD Suravee Suthikulpanit
2022-04-05 23:08 ` [PATCH 03/12] KVM: SVM: Detect X2APIC virtualization (x2AVIC) support Suravee Suthikulpanit
2022-04-05 23:08 ` [PATCH 04/12] KVM: SVM: Update max number of vCPUs supported for x2AVIC mode Suravee Suthikulpanit
2022-04-05 23:08 ` [PATCH 05/12] KVM: SVM: Update avic_kick_target_vcpus to support 32-bit APIC ID Suravee Suthikulpanit
2022-04-05 23:08 ` [PATCH 06/12] KVM: SVM: Do not support updating APIC ID when in x2APIC mode Suravee Suthikulpanit
2022-04-05 23:08 ` [PATCH 07/12] KVM: SVM: Adding support for configuring x2APIC MSRs interception Suravee Suthikulpanit
2022-04-07  2:44   ` Suravee Suthikulpanit [this message]
2022-04-05 23:08 ` [PATCH 08/12] KVM: SVM: Update AVIC settings when changing APIC mode Suravee Suthikulpanit
2022-04-05 23:08 ` [PATCH 09/12] KVM: SVM: Introduce helper functions to (de)activate AVIC and x2AVIC Suravee Suthikulpanit
2022-04-05 23:08 ` [PATCH 10/12] KVM: SVM: Do not throw warning when calling avic_vcpu_load on a running vcpu Suravee Suthikulpanit
2022-04-05 23:08 ` [PATCH 11/12] KVM: SVM: Do not inhibit APICv when x2APIC is present Suravee Suthikulpanit
2022-04-05 23:08 ` [PATCH 12/12] kvm/x86: Remove APICV activate mode inconsistency check Suravee Suthikulpanit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dac4d609-98a3-0311-4234-1e6ba4644cb0@amd.com \
    --to=suravee.suthikulpanit@amd.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=jon.grimm@amd.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=mlevitsk@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=seanjc@google.com \
    --cc=terry.bowman@amd.com \
    --cc=tglx@linutronix.de \
    --cc=wei.huang2@amd.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®