All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Cc: Uros Bizjak <ubizjak@gmail.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v3] KVM/x86: Move definition of __ex to x86.h
Date: Mon, 21 Dec 2020 15:05:08 -0800	[thread overview]
Message-ID: <X+EqJB/k1kxSWE7m@google.com> (raw)
In-Reply-To: <a773afca-7f28-2392-74ad-0895da3f75ca@oracle.com>

On Mon, Dec 21, 2020, Krish Sadhukhan wrote:
> 
> On 12/21/20 11:48 AM, Uros Bizjak wrote:
> > diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
> > index c5ee0f5ce0f1..5b16d2b5c3bc 100644
> > --- a/arch/x86/kvm/x86.h
> > +++ b/arch/x86/kvm/x86.h
> > @@ -8,6 +8,30 @@
> >   #include "kvm_cache_regs.h"
> >   #include "kvm_emulate.h"
> > +asmlinkage void kvm_spurious_fault(void);
> > +
> > +/*
> > + * Handle a fault on a hardware virtualization (VMX or SVM) instruction.
> > + *
> > + * Hardware virtualization extension instructions may fault if a reboot turns
> > + * off virtualization while processes are running.  Usually after catching the
> > + * fault we just panic; during reboot instead the instruction is ignored.
> > + */
> > +#define __ex(insn)							\
> 
> 
> While the previous name was too elaborate, this new name is very cryptic. 
> Unless we are saving for space,it's better to give a somewhat descriptive
> name.

We are saving for space in a way.  Not so much to actually save lines of code,
but to avoid stealing the focus from the code that matters.  __ex() is cryptic
for the completely unfamiliar, but I'm worried that anything more verbose will
harm the readability of the code where it is used, which is usually what's more
important in the long run.  

__ex() does have some meaning, as it's connected to the various ex_handler_*()
helpers.  ex_handle() is the best semi-verbose alternative that I can think of,
but even that is too long for my liking when reading the inline asm flows.  And
it's not like ex_handle() tells the whole story; the reader still has to go to
the definition to understand what it does, or worse, will make incorrect
assumptions about how exceptions are handled.

E.g. with the short version, my eyes gravitate toward vmxoff/vmsave without
getting stuck on the verbose wrapper.

	asm volatile (__ex("vmxoff"));

	asm volatile(__ex("vmsave") : : "a" (__sme_page_pa(sd->save_area)) : "memory");

vs.

	asm volatile (ex_handle("vmxoff"));

	asm volatile(ex_handle("vmsave") : : "a" (__sme_page_pa(sd->save_area)) : "memory");

  parent reply	other threads:[~2020-12-21 23:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-21 19:48 [PATCH v3] KVM/x86: Move definition of __ex to x86.h Uros Bizjak
2020-12-21 22:00 ` Krish Sadhukhan
2020-12-21 22:10   ` Uros Bizjak
2020-12-21 23:05   ` Sean Christopherson [this message]
2020-12-28 23:54 ` Sean Christopherson
2020-12-29 22:14   ` 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=X+EqJB/k1kxSWE7m@google.com \
    --to=seanjc@google.com \
    --cc=krish.sadhukhan@oracle.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=ubizjak@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.