From: "Suthikulpanit, Suravee" <Suravee.Suthikulpanit@amd.com>
To: Alexander Graf <graf@amazon.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Cc: "pbonzini@redhat.com" <pbonzini@redhat.com>,
"rkrcmar@redhat.com" <rkrcmar@redhat.com>,
"joro@8bytes.org" <joro@8bytes.org>,
"jschoenh@amazon.de" <jschoenh@amazon.de>,
"karahmed@amazon.de" <karahmed@amazon.de>,
"rimasluk@amazon.com" <rimasluk@amazon.com>,
"Grimm, Jon" <Jon.Grimm@amd.com>
Subject: Re: [PATCH v2 02/15] kvm: x86: Introduce KVM APICv state
Date: Mon, 26 Aug 2019 19:06:01 +0000 [thread overview]
Message-ID: <869df1a2-eb09-c68d-e1eb-053b3d60787e@amd.com> (raw)
In-Reply-To: <7c71379b-d94c-dc8e-f684-331183f8a594@amazon.com>
Alex,
On 8/19/2019 4:49 AM, Alexander Graf wrote:
>
>
> On 15.08.19 18:25, Suthikulpanit, Suravee wrote:
>> Currently, after a VM boots with APICv enabled, it could go into
>> the following states:
>> * activated = VM is running w/ APICv
>> * deactivated = VM deactivate APICv (temporary)
>> * disabled = VM deactivate APICv (permanent)
>>
>> Introduce KVM APICv state enum to help keep track of the APICv states
>> along with a new variable struct kvm_arch.apicv_state to store
>> the current state.
>>
>> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
>> ---
>> arch/x86/include/asm/kvm_host.h | 11 +++++++++++
>> arch/x86/kvm/x86.c | 14 +++++++++++++-
>> 2 files changed, 24 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
>> index 56bc702..04d7066 100644
>> --- a/arch/x86/include/asm/kvm_host.h
>> +++ b/arch/x86/include/asm/kvm_host.h
>> @@ -845,6 +845,15 @@ enum kvm_irqchip_mode {
>> KVM_IRQCHIP_SPLIT, /* created with KVM_CAP_SPLIT_IRQCHIP */
>> };
>> +/*
>> + * KVM assumes all vcpus in a VM operate in the same mode.
>> + */
>> +enum kvm_apicv_state {
>> + APICV_DISABLED, /* Disabled (such as for Hyper-V case) */
>> + APICV_DEACTIVATED, /* Deactivated tempoerary */
>
> typo
>
> I'm also not sure the name is 100% obvious. How about something like "suspended" or "paused"?
Ok, I'll change it to APICV_SUSPENDED.
>> ...
>> @@ -9150,13 +9154,18 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
>> goto fail_free_pio_data;
>> if (irqchip_in_kernel(vcpu->kvm)) {
>> - vcpu->arch.apicv_active = kvm_x86_ops->get_enable_apicv(vcpu->kvm);
>
> Why are you moving this into a locked section?
Since we introduced the apicv_state to track the VM APICv state, which is accessible
by each vcpu initialization code, we need to lock and check the state before setting
the per-vcpu apicv_active.
>
>> r = kvm_create_lapic(vcpu, lapic_timer_advance_ns);
>> if (r < 0)
>> goto fail_mmu_destroy;
>> } else
>> static_key_slow_inc(&kvm_no_apic_vcpu);
>> + mutex_lock(&vcpu->kvm->arch.apicv_lock);
>> + if (irqchip_in_kernel(vcpu->kvm) &&
>> + vcpu->kvm->arch.apicv_state == APICV_ACTIVATED)
>> + vcpu->arch.apicv_active = kvm_x86_ops->get_enable_apicv(vcpu->kvm);
>> + mutex_unlock(&vcpu->kvm->arch.apicv_lock);
>> +
>> vcpu->arch.mce_banks = kzalloc(KVM_MAX_MCE_BANKS * sizeof(u64) * 4,
>> GFP_KERNEL_ACCOUNT);
>> if (!vcpu->arch.mce_banks) {
>> @@ -9255,6 +9264,9 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
>> kvm_page_track_init(kvm);
>> kvm_mmu_init_vm(kvm);
>> + /* APICV initialization */
>> + mutex_init(&kvm->arch.apicv_lock);
>
> In fact, the whole lock story is not part of the patch description :).\\
Ok, I'll update the commit log to describe the lock .
Suravee
next prev parent reply other threads:[~2019-08-26 19:06 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-15 16:25 [PATCH v2 00/15] kvm: x86: Support AMD SVM AVIC w/ in-kernel irqchip mode Suthikulpanit, Suravee
2019-08-15 16:25 ` [PATCH v2 01/15] kvm: x86: Modify kvm_x86_ops.get_enable_apicv() to use struct kvm parameter Suthikulpanit, Suravee
2019-08-27 7:15 ` Vitaly Kuznetsov
2019-08-15 16:25 ` [PATCH v2 02/15] kvm: x86: Introduce KVM APICv state Suthikulpanit, Suravee
2019-08-19 9:49 ` Alexander Graf
2019-08-26 19:06 ` Suthikulpanit, Suravee [this message]
2019-08-15 16:25 ` [PATCH v2 03/15] kvm: Add arch-specific per-VM debugfs support Suthikulpanit, Suravee
2019-08-15 16:25 ` [PATCH v2 04/15] kvm: x86: Add per-VM APICv state debugfs Suthikulpanit, Suravee
2019-08-19 9:57 ` Alexander Graf
2019-08-26 19:41 ` Suthikulpanit, Suravee
2019-08-27 8:20 ` Alexander Graf
2019-08-28 18:39 ` Suthikulpanit, Suravee
2019-08-28 19:36 ` Graf (AWS), Alexander
2019-08-15 16:25 ` [PATCH v2 05/15] kvm: lapic: Introduce APICv update helper function Suthikulpanit, Suravee
2019-08-27 7:22 ` Vitaly Kuznetsov
2019-08-15 16:25 ` [PATCH v2 06/15] kvm: x86: Add support for activate/de-activate APICv at runtime Suthikulpanit, Suravee
2019-08-27 7:29 ` Vitaly Kuznetsov
2019-08-27 8:05 ` Alexander Graf
2019-08-15 16:25 ` [PATCH v2 07/15] kvm: x86: svm: Add support to activate/deactivate posted interrupts Suthikulpanit, Suravee
2019-08-15 16:25 ` [PATCH v2 08/15] svm: Add support for setup/destroy virutal APIC backing page for AVIC Suthikulpanit, Suravee
2019-08-15 16:25 ` [PATCH v2 09/15] svm: Add support for activate/deactivate AVIC at runtime Suthikulpanit, Suravee
2019-08-19 10:28 ` Alexander Graf
2019-08-15 16:25 ` [PATCH v2 10/15] kvm: x86: hyperv: Use APICv deactivate request interface Suthikulpanit, Suravee
2019-08-19 10:31 ` Alexander Graf
2019-08-15 16:25 ` [PATCH v2 11/15] svm: Temporary deactivate AVIC during ExtINT handling Suthikulpanit, Suravee
2019-08-19 10:35 ` Alexander Graf
2019-08-28 15:17 ` Suthikulpanit, Suravee
2019-08-28 19:37 ` Graf (AWS), Alexander
2019-09-10 15:46 ` Suthikulpanit, Suravee
2019-08-15 16:25 ` [PATCH v2 12/15] kvm: i8254: Check LAPIC EOI pending when injecting irq on SVM AVIC Suthikulpanit, Suravee
2019-08-19 10:42 ` Alexander Graf
2019-08-26 20:46 ` Suthikulpanit, Suravee
2019-08-27 9:10 ` Alexander Graf
2019-09-13 14:50 ` Suthikulpanit, Suravee
2019-08-15 16:25 ` [PATCH v2 13/15] kvm: lapic: Clean up APIC predefined macros Suthikulpanit, Suravee
2019-08-15 16:25 ` [PATCH v2 14/15] kvm: ioapic: Delay update IOAPIC EOI for RTC Suthikulpanit, Suravee
2019-08-19 11:00 ` Alexander Graf
2019-09-04 2:06 ` Suthikulpanit, Suravee
2019-08-15 16:25 ` [PATCH v2 15/15] svm: Allow AVIC with in-kernel irqchip mode Suthikulpanit, Suravee
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=869df1a2-eb09-c68d-e1eb-053b3d60787e@amd.com \
--to=suravee.suthikulpanit@amd.com \
--cc=Jon.Grimm@amd.com \
--cc=graf@amazon.com \
--cc=joro@8bytes.org \
--cc=jschoenh@amazon.de \
--cc=karahmed@amazon.de \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rimasluk@amazon.com \
--cc=rkrcmar@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).