Re: [PATCH] KVM/x86: increase frame warning limit in emulate when using KASAN or KCSAN

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 13, 2024, flyingpenghao@xxxxxxxxx wrote:
> From: Peng Hao <flyingpeng@xxxxxxxxxxx>
> 
>  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@xxxxxxxxxx>
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@xxxxxxxxxx>
---
 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


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux