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] KVM/x86: increase frame warning limit in emulate when using KASAN or KCSAN
Date: Thu, 13 Jun 2024 12:17:25 -0700 [thread overview]
Message-ID: <ZmtFxVTnzS8z3n5m@google.com> (raw)
In-Reply-To: <20240613021920.46508-1-flyingpeng@tencent.com>
On Thu, Jun 13, 2024, flyingpenghao@gmail.com wrote:
> From: Peng Hao <flyingpeng@tencent.com>
>
> When building kernel with clang, which will typically
> have sanitizers enabled, there is a warning about a large stack frame.
>
> arch/x86/kvm/emulate.c:3022:5: error: stack frame size (2520) exceeds limit (2048)
> in 'emulator_task_switch' [-Werror,-Wframe-larger-than]
> int emulator_task_switch(struct x86_emulate_ctxt *ctxt,
> ^
> 599/2520 (23.77%) spills, 1921/2520 (76.23%) variables
>
> so increase the limit for configurations that have KASAN or KCSAN enabled for not
> breaking the majority of builds.
Overriding -Wframe-larger-than in KVM isn't maintainble or robust, and KVM shouldn't
discard the userspace configuration.
Can you provide the relevant pieces of your .config? KVM already guards against
KASAN, so maybe it's just KCSAN that's problematic? If that's the case, then I
believe the below two patches will do the trick.
If KVM_WERROR is enabled because WERROR is enabled, then that's working as intended,
i.e. the problem is in the config, not in KVM.
From: Sean Christopherson <seanjc@google.com>
Date: Thu, 13 Jun 2024 12:03:13 -0700
Subject: [PATCH 1/2] KVM: x86: Disallow KVM_WERROR if KCSAN and/or KMSAN is
enabled
Extend KVM_WERROR's incompatibility list to include KCSAN and KMSAN, in
addition to the existing KASAN restriction. Like KASAN, KCSAN and KMSAN
require more memory and can cause problems with FRAME_WARN.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/Kconfig | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig
index 80e5afde69f4..e12733574e92 100644
--- a/arch/x86/kvm/Kconfig
+++ b/arch/x86/kvm/Kconfig
@@ -61,13 +61,14 @@ config KVM
config KVM_WERROR
bool "Compile KVM with -Werror"
- # Disallow KVM's -Werror if KASAN is enabled, e.g. to guard against
- # randomized configs from selecting KVM_WERROR=y, which doesn't play
- # nice with KASAN. KASAN builds generates warnings for the default
- # FRAME_WARN, i.e. KVM_WERROR=y with KASAN=y requires special tuning.
- # Building KVM with -Werror and KASAN is still doable via enabling
- # the kernel-wide WERROR=y.
- depends on KVM && ((EXPERT && !KASAN) || WERROR)
+ # Disallow KVM's -Werror if one or more sanitizers that requires extra
+ # memory is enabled, e.g. to guard against randomized configs selecting
+ # KVM_WERROR=y. Sanitizers often trip FRAME_WARN in KVM, i.e. enabling
+ # sanitizers+KVM_WERROR typically requires a hand-tuned config.
+ #
+ # Note, building KVM with -Werror and sanitizers is still doable via
+ # enabling the kernel-wide WERROR=y.
+ depends on KVM && ((EXPERT && (!KASAN && !KCSAN && !KMSAN)) || WERROR)
help
Add -Werror to the build flags for KVM.
base-commit: e4e9e1067138e5620cf0500c3e5f6ebfb9d322c8
--
2.45.2.627.g7a2c4fd464-goog
From 2e20a81fbafb10eae6727fdf314404b67b449492 Mon Sep 17 00:00:00 2001
From: Sean Christopherson <seanjc@google.com>
Date: Thu, 13 Jun 2024 12:06:36 -0700
Subject: [PATCH 2/2] KVM: x86: Disallow KVM_WERROR with sanitizers iff
FRAME_WARN is enabled
Allow KVM_WERROR to be enabled alongside sanitizers if FRAME_WARN is
disabled, as the sanitizers are problematic only because they increase the
stack footprint and cause FRAME_WARN to fire, i.e. KVM isn't fundamentally
incompatible with the sanitizers.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/Kconfig | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig
index e12733574e92..34f047426a71 100644
--- a/arch/x86/kvm/Kconfig
+++ b/arch/x86/kvm/Kconfig
@@ -62,13 +62,14 @@ config KVM
config KVM_WERROR
bool "Compile KVM with -Werror"
# Disallow KVM's -Werror if one or more sanitizers that requires extra
- # memory is enabled, e.g. to guard against randomized configs selecting
- # KVM_WERROR=y. Sanitizers often trip FRAME_WARN in KVM, i.e. enabling
- # sanitizers+KVM_WERROR typically requires a hand-tuned config.
+ # memory is enabled and FRAME_WARN is also enabled, e.g. to guard
+ # against randomized configs selecting KVM_WERROR=y. Sanitizers often
+ # trip FRAME_WARN in KVM, i.e. enabling sanitizers+KVM_WERROR typically
+ # requires a hand-tuned config.
#
# Note, building KVM with -Werror and sanitizers is still doable via
# enabling the kernel-wide WERROR=y.
- depends on KVM && ((EXPERT && (!KASAN && !KCSAN && !KMSAN)) || WERROR)
+ depends on KVM && ((EXPERT && ((!KASAN && !KCSAN && !KMSAN) || FRAME_WARN=0)) || WERROR)
help
Add -Werror to the build flags for KVM.
--
2.45.2.627.g7a2c4fd464-goog
prev parent reply other threads:[~2024-06-13 19:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-13 2:19 [PATCH] KVM/x86: increase frame warning limit in emulate when using KASAN or KCSAN flyingpenghao
2024-06-13 19:17 ` 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=ZmtFxVTnzS8z3n5m@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