kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Uros Bizjak <ubizjak@gmail.com>
Cc: kvm@vger.kernel.org, x86@kernel.org,
	linux-kernel@vger.kernel.org,
	 Paolo Bonzini <pbonzini@redhat.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	 Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>, Borislav Petkov <bp@alien8.de>,
	 Dave Hansen <dave.hansen@linux.intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH 1/2] KVM: x86: Use asm_inline() instead of asm() in kvm_hypercall[0-4]()
Date: Mon, 14 Apr 2025 18:04:53 -0700	[thread overview]
Message-ID: <Z_2wtfAAxb5uNP4g@google.com> (raw)
In-Reply-To: <20250414081131.97374-1-ubizjak@gmail.com>

Nit, this is guest code, i.e. should use "kvm/x86:" for the scope.  No need to
send a new version just for that.

On Mon, Apr 14, 2025, Uros Bizjak wrote:
> Use asm_inline() to instruct the compiler that the size of asm()
> is the minimum size of one instruction, ignoring how many instructions
> the compiler thinks it is. ALTERNATIVE macro that expands to several
> pseudo directives causes instruction length estimate to count
> more than 20 instructions.
> 
> bloat-o-meter reports minimal code size increase
> (x86_64 defconfig, gcc-14.2.1):
> 
>   add/remove: 0/0 grow/shrink: 1/0 up/down: 10/0 (10)
> 
> 	Function                          old     new   delta
> 	-----------------------------------------------------
> 	__send_ipi_mask                   525     535     +10
> 
>   Total: Before=23751224, After=23751234, chg +0.00%
> 
> due to different compiler decisions with more precise size
> estimations.
> 
> No functional change intended.
> 
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> Cc: Sean Christopherson <seanjc@google.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> ---
>  arch/x86/include/asm/kvm_para.h | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm_para.h
> index 57bc74e112f2..519ab5aee250 100644
> --- a/arch/x86/include/asm/kvm_para.h
> +++ b/arch/x86/include/asm/kvm_para.h
> @@ -38,7 +38,7 @@ static inline long kvm_hypercall0(unsigned int nr)
>  	if (cpu_feature_enabled(X86_FEATURE_TDX_GUEST))
>  		return tdx_kvm_hypercall(nr, 0, 0, 0, 0);
>  
> -	asm volatile(KVM_HYPERCALL
> +	asm_inline volatile(KVM_HYPERCALL
>  		     : "=a"(ret)
>  		     : "a"(nr)
>  		     : "memory");
> @@ -52,7 +52,7 @@ static inline long kvm_hypercall1(unsigned int nr, unsigned long p1)
>  	if (cpu_feature_enabled(X86_FEATURE_TDX_GUEST))
>  		return tdx_kvm_hypercall(nr, p1, 0, 0, 0);
>  
> -	asm volatile(KVM_HYPERCALL
> +	asm_inline volatile(KVM_HYPERCALL
>  		     : "=a"(ret)
>  		     : "a"(nr), "b"(p1)
>  		     : "memory");
> @@ -67,7 +67,7 @@ static inline long kvm_hypercall2(unsigned int nr, unsigned long p1,
>  	if (cpu_feature_enabled(X86_FEATURE_TDX_GUEST))
>  		return tdx_kvm_hypercall(nr, p1, p2, 0, 0);
>  
> -	asm volatile(KVM_HYPERCALL
> +	asm_inline volatile(KVM_HYPERCALL
>  		     : "=a"(ret)
>  		     : "a"(nr), "b"(p1), "c"(p2)
>  		     : "memory");
> @@ -82,7 +82,7 @@ static inline long kvm_hypercall3(unsigned int nr, unsigned long p1,
>  	if (cpu_feature_enabled(X86_FEATURE_TDX_GUEST))
>  		return tdx_kvm_hypercall(nr, p1, p2, p3, 0);
>  
> -	asm volatile(KVM_HYPERCALL
> +	asm_inline volatile(KVM_HYPERCALL
>  		     : "=a"(ret)
>  		     : "a"(nr), "b"(p1), "c"(p2), "d"(p3)
>  		     : "memory");
> @@ -98,7 +98,7 @@ static inline long kvm_hypercall4(unsigned int nr, unsigned long p1,
>  	if (cpu_feature_enabled(X86_FEATURE_TDX_GUEST))
>  		return tdx_kvm_hypercall(nr, p1, p2, p3, p4);
>  
> -	asm volatile(KVM_HYPERCALL
> +	asm_inline volatile(KVM_HYPERCALL
>  		     : "=a"(ret)
>  		     : "a"(nr), "b"(p1), "c"(p2), "d"(p3), "S"(p4)
>  		     : "memory");
> -- 
> 2.49.0
> 

  parent reply	other threads:[~2025-04-15  1:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-14  8:10 [PATCH 1/2] KVM: x86: Use asm_inline() instead of asm() in kvm_hypercall[0-4]() Uros Bizjak
2025-04-14  8:10 ` [PATCH 2/2] KVM: VMX: Use LEAVE in vmx_do_interrupt_irqoff() Uros Bizjak
2025-04-15  1:05   ` Sean Christopherson
2025-04-15  7:42     ` Uros Bizjak
2025-04-15  1:04 ` Sean Christopherson [this message]
2025-04-25 23:23 ` [PATCH 1/2] KVM: x86: Use asm_inline() instead of asm() in kvm_hypercall[0-4]() 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=Z_2wtfAAxb5uNP4g@google.com \
    --to=seanjc@google.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=ubizjak@gmail.com \
    --cc=vkuznets@redhat.com \
    --cc=x86@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).