public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: flyingpenghao@gmail.com
Cc: pbonzini@redhat.com, kvm@vger.kernel.org,
	 Peng Hao <flyingpeng@tencent.com>
Subject: Re: [PATCH v2]   KVM/x86: make function emulator_do_task_switch as noinline_for_stack
Date: Fri, 12 Jul 2024 07:51:33 -0700	[thread overview]
Message-ID: <ZpFC9Q6Sccy6mjRN@google.com> (raw)
In-Reply-To: <20240712075022.48276-1-flyingpeng@tencent.com>

On Fri, Jul 12, 2024, flyingpenghao@gmail.com wrote:
> From: Peng Hao <flyingpeng@tencent.com>
> 
> When KASAN is enabled and built with clang:
> clang report
> arch/x86/kvm/emulate.c:3022:5: error: stack frame size (2488) exceeds limit (2048) in 'emulator_task_switch' [-Werror,-Wframe-larger-than]
> int emulator_task_switch(struct x86_emulate_ctxt *ctxt,
>     ^
> 
> since emulator_do_task_switch() consumes a lot of stack space, mark it as
> noinline_for_stack to prevent it from blowing up emulator_task_switch()'s
> stack size.

No, sprinkling noinline to combat KASAN stack frame sizes is not a maintainable
approach.  Practically speaking, KASAN + -Werror + FRAME_WARN=2048 is not a sane
config.

> Signed-off-by: Peng Hao <flyingpeng@tencent.com>
> ---
>  arch/x86/kvm/emulate.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index 5d4c86133453..bbc185b9725d 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -2918,7 +2918,7 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt, u16 old_tss_sel,
>  	return load_state_from_tss32(ctxt, &tss_seg);
>  }
>  
> -static int emulator_do_task_switch(struct x86_emulate_ctxt *ctxt,
> +static noinline_for_stack int emulator_do_task_switch(struct x86_emulate_ctxt *ctxt,
>  				   u16 tss_selector, int idt_index, int reason,
>  				   bool has_error_code, u32 error_code)
>  {
> -- 
> 2.27.0
> 

      reply	other threads:[~2024-07-12 14:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-12  7:50 [PATCH v2] KVM/x86: make function emulator_do_task_switch as noinline_for_stack flyingpenghao
2024-07-12 14:51 ` Sean Christopherson [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=ZpFC9Q6Sccy6mjRN@google.com \
    --to=seanjc@google.com \
    --cc=flyingpeng@tencent.com \
    --cc=flyingpenghao@gmail.com \
    --cc=kvm@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox