All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: David Woodhouse <dwmw2@infradead.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Paul Durrant <paul@xen.org>
Subject: Re: [PATCH] KVM: x86/xen: Make number of event channels defines less magical
Date: Mon, 14 Nov 2022 19:39:01 +0000	[thread overview]
Message-ID: <Y3KZVUCCH+YQDbqu@google.com> (raw)
In-Reply-To: <629d6d90ce95b9db74f0101a4428be1119c4bfc7.camel@infradead.org>

On Mon, Nov 14, 2022, David Woodhouse wrote:
> On Mon, 2022-11-14 at 18:16 +0000, Sean Christopherson wrote:
> > Use BITS_PER_BYTE and sizeof_field() to compute the number of Xen event
> > channels.  The compat version at least uses sizeof_field(), but the
> > regular version open codes sizeof_field(), BITS_PER_BYTE, and combines
> > literals in the process, which makes it far too difficult to understand
> > relatively straightforward code.
> > 
> > No functional change intended.
> 
> Slightly dubious about changing the regular one, since that's just
> imported directly from Xen public header files.

Ugh.  I worried that might be the case.  An alternative approach to help document
things from a KVM perspective would be something like:

diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c
index 93c628d3e3a9..7769f3b98af0 100644
--- a/arch/x86/kvm/xen.c
+++ b/arch/x86/kvm/xen.c
@@ -1300,6 +1300,9 @@ int kvm_xen_hypercall(struct kvm_vcpu *vcpu)
 
 static inline int max_evtchn_port(struct kvm *kvm)
 {
+       BUILD_BUG_ON(EVTCHN_2L_NR_CHANNELS !=
+                    (sizeof_field(struct shared_info, evtchn_pending) * BITS_PER_BYTE));
+
        if (IS_ENABLED(CONFIG_64BIT) && kvm->arch.xen.long_mode)
                return EVTCHN_2L_NR_CHANNELS;
        else


  reply	other threads:[~2022-11-14 19:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-14 18:16 [PATCH] KVM: x86/xen: Make number of event channels defines less magical Sean Christopherson
2022-11-14 18:39 ` David Woodhouse
2022-11-14 19:39   ` Sean Christopherson [this message]
2022-11-14 22:24     ` David Woodhouse
2022-11-22 20:31       ` Sean Christopherson
2022-11-22 23:48         ` David Woodhouse
2022-11-23 17:48           ` Sean Christopherson

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=Y3KZVUCCH+YQDbqu@google.com \
    --to=seanjc@google.com \
    --cc=dwmw2@infradead.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul@xen.org \
    --cc=pbonzini@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 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.