Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4013814pxj; Mon, 21 Jun 2021 11:27:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfV9uMYhz+SExMI9tlz/cMazHGzCKjQSR3eTdCMTM6XgHvtEQ5NufV845sOs2TTmdirh3S X-Received: by 2002:a92:3f08:: with SMTP id m8mr18535715ila.104.1624300032653; Mon, 21 Jun 2021 11:27:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624300032; cv=none; d=google.com; s=arc-20160816; b=Vb9DpejdIEuKkBIRC8diio58BkZRcfPZ1CJSn8PyrPKQNUtcC1QoteUES1u/kaPp/x I2y2Qw4pibYzJhZ9qBVKhtsq6/dqtz5HJkb7FIn442pEz+rFi4NcD9JmFh+/8qR9s3Rd tgVSbHpPTFGFZjUPbR0PpXAxqVgoWQ03c4aXS4KWEUHxZmGbHwItNEYrExKaFi4X/1wf d0whS139F1k5xuDus+SgHorBPKWSJ5JdEmCEzm2U1OnmGPZ3iWdlZEnaEpBc3sO35kuO JLF6rhURcpbHnzW1eZjQW3xGz8vFWANsQLwS/54rH3HN6op5GWnR5DmyyNuoF8qQkZ+9 E5vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=O2y6A9Hj20lbzmcHYnCG1jgFL0NUc+gNMXfxG38gGBk=; b=b1TEYeThB7O1HyQbdAaX/CarhSbuCj/kkXW3feYUdfa5f4AIihUA79t2+oAkejQFCb W9IVgrYqIxR10FwyR+w0PdBFpd5F9LRk0+atO3nI30WheLefRGNCrnM6F/tNIalKMNml rcgzRPrgeAeTmji7SuESUD0RcCUGGdswWR7/FPJrUvMmsXzGJN3IdRDhyUfJ4nSLCSN3 wWOnnQ22i2sSC1Me3mgIrPIvhxqDKdyX8ZhEIT5ozuxy6zv54YlYaZUnHI2OKRNJd7kG iTKEAh/dPT+SFVQewKE3grxB++3H+0SLu/VQ3Br7YMCNSwqN7TCVLVrPsafPLo+53c47 X55A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GkIXifsk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a13si3143990ilj.80.2021.06.21.11.27.00; Mon, 21 Jun 2021 11:27:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GkIXifsk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231923AbhFUS2H (ORCPT + 99 others); Mon, 21 Jun 2021 14:28:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:33620 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231740AbhFUS2E (ORCPT ); Mon, 21 Jun 2021 14:28:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EDD606054E; Mon, 21 Jun 2021 18:25:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624299950; bh=xDbIiO2U9PPPDA8IGdGJB0YSQtthnxnEYlLcPl6LzZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GkIXifskbHUdNDMnLgqEC7yGxDgDNaOjFv4ijENR4xtQgB4IlqFLUhws3uDzaHCAe oe754NLbUUOcWj8kGxvcSm+XpWorxq6SUN6Ee14MNuAeX2JFP60a2iqEb+t//jGEEs exv5CxQf4pNUkVEwnLYWX7hYx/jD90o5aq2EYafYxfmvu+gl5Wpo47O7L067tHUti2 85BH/cU89909Y7F8tI3r/ezdg6IUWHAyX1Y3QP47u0VdMtFy7G5y/YPtgSLbXOLNTC M7C78CmwvzltAta+/dJw/R5UIFidoUHlvBzsIGbsb/aex5Cd8wbwxxomH7JrUuoryt V8fro9fatTHoQ== From: Nathan Chancellor To: Paul Mackerras , Michael Ellerman Cc: Benjamin Herrenschmidt , Nick Desaulniers , kvm-ppc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Nicholas Piggin , Arnd Bergmann , Nathan Chancellor , kernel test robot Subject: [PATCH] KVM: PPC: Book3S HV: Workaround high stack usage with clang Date: Mon, 21 Jun 2021 11:24:40 -0700 Message-Id: <20210621182440.990242-1-nathan@kernel.org> X-Mailer: git-send-email 2.32.0.93.g670b81a890 In-Reply-To: References: MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org LLVM does not emit optimal byteswap assembly, which results in high stack usage in kvmhv_enter_nested_guest() due to the inlining of byteswap_pt_regs(). With LLVM 12.0.0: arch/powerpc/kvm/book3s_hv_nested.c:289:6: error: stack frame size of 2512 bytes in function 'kvmhv_enter_nested_guest' [-Werror,-Wframe-larger-than=] long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu) ^ 1 error generated. While this gets fixed in LLVM, mark byteswap_pt_regs() as noinline_for_stack so that it does not get inlined and break the build due to -Werror by default in arch/powerpc/. Not inlining saves approximately 800 bytes with LLVM 12.0.0: arch/powerpc/kvm/book3s_hv_nested.c:290:6: warning: stack frame size of 1728 bytes in function 'kvmhv_enter_nested_guest' [-Wframe-larger-than=] long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu) ^ 1 warning generated. Link: https://github.com/ClangBuiltLinux/linux/issues/1292 Link: https://bugs.llvm.org/show_bug.cgi?id=49610 Link: https://lore.kernel.org/r/202104031853.vDT0Qjqj-lkp@intel.com/ Link: https://gist.github.com/ba710e3703bf45043a31e2806c843ffd Reported-by: kernel test robot Signed-off-by: Nathan Chancellor --- arch/powerpc/kvm/book3s_hv_nested.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kvm/book3s_hv_nested.c b/arch/powerpc/kvm/book3s_hv_nested.c index 60724f674421..1b3ff0af1264 100644 --- a/arch/powerpc/kvm/book3s_hv_nested.c +++ b/arch/powerpc/kvm/book3s_hv_nested.c @@ -53,7 +53,8 @@ void kvmhv_save_hv_regs(struct kvm_vcpu *vcpu, struct hv_guest_state *hr) hr->dawrx1 = vcpu->arch.dawrx1; } -static void byteswap_pt_regs(struct pt_regs *regs) +/* Use noinline_for_stack due to https://bugs.llvm.org/show_bug.cgi?id=49610 */ +static noinline_for_stack void byteswap_pt_regs(struct pt_regs *regs) { unsigned long *addr = (unsigned long *) regs; base-commit: 4a21192e2796c3338c4b0083b494a84a61311aaf -- 2.32.0.93.g670b81a890