From: "Radim Krčmář" <rkrcmar@redhat.com>
To: James Sullivan <sullivan.james.f@gmail.com>
Cc: kvm@vger.kernel.org, gleb@kernel.org, pbonzini@redhat.com
Subject: Re: [PATCH v2] x86: irq_comm: Add check for RH bit in kvm_set_msi_irq
Date: Thu, 12 Mar 2015 16:39:45 +0100 [thread overview]
Message-ID: <20150312153945.GA30148@potion.brq.redhat.com> (raw)
In-Reply-To: <550059B6.6050708@gmail.com>
2015-03-11 09:05-0600, James Sullivan:
> This is a revised patch to the previous submission, adding a check for RH=1/DM=1
> in kvm_set_msi_irq.
(Btw. you can put it below the /^---$/ line, where it gets automatically
trimmed -- information on changes since the last version is very
important in review, but of little use later.)
> This patch doesn't completely handle RH=1; if RH=1 then the delivery will behave
> as in low priority mode (deliver the interrupt to only the lowest priority processor),
> but the delivery mode is still used to specify the semantics of the delivery beyond
> its destination. We can't just set irq->delivery_mode to APIC_DM_LOWPRI if RH=1 since
> this squashes the other delivery semantics. I've documented this in the patch.
It's possible that hardware designers didn't want to waste silicon
either, thus overwriting delivery mode would be the correct, and easy,
thing to do. (Or have I missed its definition?)
> A future fix may be to implement a separate interrupt delivery function for MSI
> interrupts in kvm_set_msi, which is a bit hacky but probably the only way to do this
> without modifying the kvm_lapic_irq struct. I'll write this up and see how it looks,
> unless there are major objections.
Thank you; no objections without patches :)
I think that exploring other options makes sense here.
We would probably re-implement most of the code, so adding extra
parameter to interrupt delivery functions would be easier to maintain.
Extending 'struct kvm_lapic_irq' seems acceptable too: it's an internal
structure and we already have kvm_is_dm_lowest_prio() helper.
> diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c
> @@ -97,18 +97,34 @@ int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src,
> static inline void kvm_set_msi_irq(struct kvm_kernel_irq_routing_entry *e,
> struct kvm_lapic_irq *irq)
> {
> + bool phys;
> trace_kvm_msi_set_irq(e->msi.address_lo, e->msi.data);
(We usually have have an empty line after declarations.
I've seen patches that fixed just this, because some tool complains.)
> + /*
> + * Set dest_mode to logical just in case both RH=1/DH=1,
> + * otherwise default to physical
> + */
This comment contains the same algorithm written in other (less defined)
language, right next to a similarly complex implementation ...
> + phys = ((e->msi.address_lo & (MSI_ADDR_REDIRECTION_LOWPRI |
> + MSI_ADDR_DEST_MODE_LOGICAL)) !=
> + (MSI_ADDR_REDIRECTION_LOWPRI |
> + MSI_ADDR_DEST_MODE_LOGICAL));
> + irq->dest_mode = phys ? APIC_DEST_PHYSICAL : APIC_DEST_LOGICAL;
Wouldn't changing white spacing, using 'if', defining a union mask,
abstracting the all-bits-in-mask-are-set operation, or something help to
make this code clear without a comment?
> irq->delivery_mode = e->msi.data & 0x700;
A system that configured DM and RH might not handle delivery to multiple
APICs. Please add a warning (once), to ease debugging if/when this
feature gets its first user.
Thanks.
> +· /*
> +· * TODO Deal with RH bit of MSI message address
> +· * IF RH=1, then MSI delivers only to the processor with the
> +· * lowest interrupt priority among processors that can receive
> +· * the interrupt. However other delivery semantics are still
> +· * specified by the delivery mode, so we can't default to
> +· * APIC_DM_LOWPRI if RH=1.
> +· */
(We would, if there was some benefit in erring that way.)
prev parent reply other threads:[~2015-03-12 15:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-10 5:05 [PATCH] x86: irq_comm: Add check for RH bit in kvm_set_msi_irq James Sullivan
2015-03-10 14:47 ` Radim Krčmář
2015-03-10 22:39 ` James Sullivan
2015-03-11 13:43 ` Radim Krčmář
2015-03-11 14:38 ` James Sullivan
2015-03-11 15:05 ` [PATCH v2] " James Sullivan
2015-03-12 15:39 ` Radim Krčmář [this message]
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=20150312153945.GA30148@potion.brq.redhat.com \
--to=rkrcmar@redhat.com \
--cc=gleb@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=sullivan.james.f@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.