From: Marcelo Tosatti <mtosatti@redhat.com>
To: Gleb Natapov <gleb@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH RFC v2 1/4] Introduce kvm_vcpu_is_bsp() function.
Date: Mon, 25 May 2009 17:46:22 -0300 [thread overview]
Message-ID: <20090525204622.GA7890@amt.cnet> (raw)
In-Reply-To: <1243266636-16914-2-git-send-email-gleb@redhat.com>
On Mon, May 25, 2009 at 06:50:33PM +0300, Gleb Natapov wrote:
> Use it instead of open code "vcpu_id zero is BSP" assumption.
>
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> ---
> arch/ia64/kvm/kvm-ia64.c | 2 +-
> arch/ia64/kvm/vcpu.c | 2 +-
> arch/x86/kvm/i8254.c | 4 ++--
> arch/x86/kvm/i8259.c | 6 +++---
> arch/x86/kvm/lapic.c | 7 ++++---
> arch/x86/kvm/svm.c | 4 ++--
> arch/x86/kvm/vmx.c | 6 +++---
> arch/x86/kvm/x86.c | 4 ++--
> include/linux/kvm_host.h | 5 +++++
> virt/kvm/ioapic.c | 4 +++-
> virt/kvm/kvm_main.c | 2 ++
> 11 files changed, 28 insertions(+), 18 deletions(-)
>
> #endif
> diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
> index 1eddae9..a8a8252 100644
> --- a/virt/kvm/ioapic.c
> +++ b/virt/kvm/ioapic.c
> @@ -165,7 +165,9 @@ static int ioapic_deliver(struct kvm_ioapic *ioapic, int irq)
> /* Always delivery PIT interrupt to vcpu 0 */
> if (irq == 0) {
> irqe.dest_mode = 0; /* Physical mode. */
> - irqe.dest_id = ioapic->kvm->vcpus[0]->vcpu_id;
> + /* need to read apic_id from apic regiest since
> + * it can be rewritten */
> + irqe.dest_id = ioapic->kvm->bsp_vcpu->vcpu_id;
> }
Won't this oops if userspace creates only vcpu 3 and attempts to deliver
to IRQ0 ? (not directly related to the patchset though).
Also you said "The code still assumes that boot cpu is created first."
Where is that?
Otherwise, neat!
> #endif
> return kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe);
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index de042cb..5a55fe0 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -1737,6 +1737,8 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n)
> goto vcpu_destroy;
> }
> kvm->vcpus[n] = vcpu;
> + if (n == 0)
> + kvm->bsp_vcpu = vcpu;
> mutex_unlock(&kvm->lock);
>
> /* Now it's all set up, let userspace reach it */
> --
> 1.6.2.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2009-05-25 20:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-25 15:50 [PATCH RFC v2 0/4] decouple vcpu index from apic id Gleb Natapov
2009-05-25 15:50 ` [PATCH RFC v2 1/4] Introduce kvm_vcpu_is_bsp() function Gleb Natapov
2009-05-25 20:46 ` Marcelo Tosatti [this message]
2009-05-26 6:12 ` Gleb Natapov
2009-05-25 15:50 ` [PATCH RFC v2 2/4] Use pointer to vcpu instead of vcpu_id in timer code Gleb Natapov
2009-05-26 8:30 ` Avi Kivity
2009-05-26 8:52 ` Gleb Natapov
2009-05-25 15:50 ` [PATCH RFC v2 3/4] Break dependency between vcpu index in vcpus array and vcpu_id Gleb Natapov
2009-05-26 8:34 ` Avi Kivity
2009-05-26 8:55 ` Gleb Natapov
2009-05-26 8:57 ` Avi Kivity
2009-05-25 15:50 ` [PATCH RFC v2 4/4] Use macro to iterate over vcpus Gleb Natapov
2009-05-26 8:18 ` Avi Kivity
2009-05-26 8:37 ` Gleb Natapov
2009-05-26 8:56 ` Avi Kivity
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=20090525204622.GA7890@amt.cnet \
--to=mtosatti@redhat.com \
--cc=gleb@redhat.com \
--cc=kvm@vger.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;
as well as URLs for NNTP newsgroup(s).