From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48D1FC49EA2 for ; Mon, 21 Jun 2021 05:53:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E71161156 for ; Mon, 21 Jun 2021 05:53:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229765AbhFUFzm (ORCPT ); Mon, 21 Jun 2021 01:55:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:56954 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbhFUFzk (ORCPT ); Mon, 21 Jun 2021 01:55:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1B3B76113C; Mon, 21 Jun 2021 05:53:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624254806; bh=VNjmysMr5aFo5Y2ewZkvwCDsHp1Bte5+E7/g36fuzzU=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=P5Wn0abpDffObFsODQBb46AJG5uEv9KMlhwnpO5l3hywP10zpyQgChYxpIIvT6C+0 lIo0YRD1ngL1aAg252d8jh7E4Fdvn3Je8gTBRPMY0eyJ0HVzsZYrdXjOMBPrYR5juR 1cpMKVxm1MJEk99eC7lX/XYt77ZMMYExCYEwTr2vdNrtReY6oB1tmI7ApA4kpu/ue+ WQldb9mRpxM6zrO+/H7AtSpmfqkknVPQoc9/jGqChsLrnxefRVe4ZsvqzB6bjwOEbl xhiUYqIn2Vc6Yyi+ktmhCNjBNK1eQfkq4XSPDDbZBahco7TTJc4KsCJa4rdZbq6MEq hnUmFO4HxHgtQ== Subject: Re: arch/powerpc/kvm/book3s_hv_nested.c:264:6: error: stack frame size of 2304 bytes in function 'kvmhv_enter_nested_guest' To: Nicholas Piggin , Arnd Bergmann , kernel test robot Cc: Andrew Morton , clang-built-linux@googlegroups.com, kbuild-all@lists.01.org, Kees Cook , linux-kernel@vger.kernel.org, Linux Memory Management List , linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org References: <202104031853.vDT0Qjqj-lkp@intel.com> <1624232938.d90brlmh3p.astroid@bobo.none> From: Nathan Chancellor Message-ID: Date: Sun, 20 Jun 2021 22:53:22 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <1624232938.d90brlmh3p.astroid@bobo.none> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/20/2021 4:59 PM, Nicholas Piggin wrote: > Excerpts from kernel test robot's message of April 3, 2021 8:47 pm: >> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master >> head: d93a0d43e3d0ba9e19387be4dae4a8d5b175a8d7 >> commit: 97e4910232fa1f81e806aa60c25a0450276d99a2 linux/compiler-clang.h: define HAVE_BUILTIN_BSWAP* >> date: 3 weeks ago >> config: powerpc64-randconfig-r006-20210403 (attached as .config) >> compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 0fe8af94688aa03c01913c2001d6a1a911f42ce6) >> reproduce (this is a W=1 build): >> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross >> chmod +x ~/bin/make.cross >> # install powerpc64 cross compiling tool for clang build >> # apt-get install binutils-powerpc64-linux-gnu >> # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=97e4910232fa1f81e806aa60c25a0450276d99a2 >> git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git >> git fetch --no-tags linus master >> git checkout 97e4910232fa1f81e806aa60c25a0450276d99a2 >> # save the attached .config to linux build tree >> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64 >> >> If you fix the issue, kindly add following tag as appropriate >> Reported-by: kernel test robot >> >> All errors (new ones prefixed by >>): >> >>>> arch/powerpc/kvm/book3s_hv_nested.c:264:6: error: stack frame size of 2304 bytes in function 'kvmhv_enter_nested_guest' [-Werror,-Wframe-larger-than=] >> long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu) >> ^ >> 1 error generated. >> >> >> vim +/kvmhv_enter_nested_guest +264 arch/powerpc/kvm/book3s_hv_nested.c > > Not much changed here recently. It's not that big a concern because it's > only called in the KVM ioctl path, not in any deep IO paths or anything, > and doesn't recurse. Might be a bit of inlining or stack spilling put it > over the edge. It appears to be the fact that LLVM's PowerPC backend does not emit efficient byteswap assembly: https://github.com/ClangBuiltLinux/linux/issues/1292 https://bugs.llvm.org/show_bug.cgi?id=49610 > powerpc does make it an error though, would be good to avoid that so the > robot doesn't keep tripping over. Marking byteswap_pt_regs as 'noinline_for_stack' drastically reduces the stack usage. If that is an acceptable solution, I can send it along tomorrow. Cheers, Nathan > Thanks, > Nick > > >> >> afe75049303f75 Ravi Bangoria 2020-12-16 263 >> 360cae313702cd Paul Mackerras 2018-10-08 @264 long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu) >> 360cae313702cd Paul Mackerras 2018-10-08 265 { >> 360cae313702cd Paul Mackerras 2018-10-08 266 long int err, r; >> 360cae313702cd Paul Mackerras 2018-10-08 267 struct kvm_nested_guest *l2; >> 360cae313702cd Paul Mackerras 2018-10-08 268 struct pt_regs l2_regs, saved_l1_regs; >> afe75049303f75 Ravi Bangoria 2020-12-16 269 struct hv_guest_state l2_hv = {0}, saved_l1_hv; >> 360cae313702cd Paul Mackerras 2018-10-08 270 struct kvmppc_vcore *vc = vcpu->arch.vcore; >> 360cae313702cd Paul Mackerras 2018-10-08 271 u64 hv_ptr, regs_ptr; >> 360cae313702cd Paul Mackerras 2018-10-08 272 u64 hdec_exp; >> 360cae313702cd Paul Mackerras 2018-10-08 273 s64 delta_purr, delta_spurr, delta_ic, delta_vtb; >> 360cae313702cd Paul Mackerras 2018-10-08 274 u64 mask; >> 360cae313702cd Paul Mackerras 2018-10-08 275 unsigned long lpcr; >> 360cae313702cd Paul Mackerras 2018-10-08 276 >> 360cae313702cd Paul Mackerras 2018-10-08 277 if (vcpu->kvm->arch.l1_ptcr == 0) >> 360cae313702cd Paul Mackerras 2018-10-08 278 return H_NOT_AVAILABLE; >> 360cae313702cd Paul Mackerras 2018-10-08 279 >> 360cae313702cd Paul Mackerras 2018-10-08 280 /* copy parameters in */ >> 360cae313702cd Paul Mackerras 2018-10-08 281 hv_ptr = kvmppc_get_gpr(vcpu, 4); >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 282 regs_ptr = kvmppc_get_gpr(vcpu, 5); >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 283 vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); >> afe75049303f75 Ravi Bangoria 2020-12-16 284 err = kvmhv_read_guest_state_and_regs(vcpu, &l2_hv, &l2_regs, >> afe75049303f75 Ravi Bangoria 2020-12-16 285 hv_ptr, regs_ptr); >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 286 srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); >> 360cae313702cd Paul Mackerras 2018-10-08 287 if (err) >> 360cae313702cd Paul Mackerras 2018-10-08 288 return H_PARAMETER; >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 289 >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 290 if (kvmppc_need_byteswap(vcpu)) >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 291 byteswap_hv_regs(&l2_hv); >> afe75049303f75 Ravi Bangoria 2020-12-16 292 if (l2_hv.version > HV_GUEST_STATE_VERSION) >> 360cae313702cd Paul Mackerras 2018-10-08 293 return H_P2; >> 360cae313702cd Paul Mackerras 2018-10-08 294 >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 295 if (kvmppc_need_byteswap(vcpu)) >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 296 byteswap_pt_regs(&l2_regs); >> 9d0b048da788c1 Suraj Jitindar Singh 2018-10-08 297 if (l2_hv.vcpu_token >= NR_CPUS) >> 9d0b048da788c1 Suraj Jitindar Singh 2018-10-08 298 return H_PARAMETER; >> 9d0b048da788c1 Suraj Jitindar Singh 2018-10-08 299 >> 360cae313702cd Paul Mackerras 2018-10-08 300 /* translate lpid */ >> 360cae313702cd Paul Mackerras 2018-10-08 301 l2 = kvmhv_get_nested(vcpu->kvm, l2_hv.lpid, true); >> 360cae313702cd Paul Mackerras 2018-10-08 302 if (!l2) >> 360cae313702cd Paul Mackerras 2018-10-08 303 return H_PARAMETER; >> 360cae313702cd Paul Mackerras 2018-10-08 304 if (!l2->l1_gr_to_hr) { >> 360cae313702cd Paul Mackerras 2018-10-08 305 mutex_lock(&l2->tlb_lock); >> 360cae313702cd Paul Mackerras 2018-10-08 306 kvmhv_update_ptbl_cache(l2); >> 360cae313702cd Paul Mackerras 2018-10-08 307 mutex_unlock(&l2->tlb_lock); >> 360cae313702cd Paul Mackerras 2018-10-08 308 } >> 360cae313702cd Paul Mackerras 2018-10-08 309 >> 360cae313702cd Paul Mackerras 2018-10-08 310 /* save l1 values of things */ >> 360cae313702cd Paul Mackerras 2018-10-08 311 vcpu->arch.regs.msr = vcpu->arch.shregs.msr; >> 360cae313702cd Paul Mackerras 2018-10-08 312 saved_l1_regs = vcpu->arch.regs; >> 360cae313702cd Paul Mackerras 2018-10-08 313 kvmhv_save_hv_regs(vcpu, &saved_l1_hv); >> 360cae313702cd Paul Mackerras 2018-10-08 314 >> 360cae313702cd Paul Mackerras 2018-10-08 315 /* convert TB values/offsets to host (L0) values */ >> 360cae313702cd Paul Mackerras 2018-10-08 316 hdec_exp = l2_hv.hdec_expiry - vc->tb_offset; >> 360cae313702cd Paul Mackerras 2018-10-08 317 vc->tb_offset += l2_hv.tb_offset; >> 360cae313702cd Paul Mackerras 2018-10-08 318 >> 360cae313702cd Paul Mackerras 2018-10-08 319 /* set L1 state to L2 state */ >> 360cae313702cd Paul Mackerras 2018-10-08 320 vcpu->arch.nested = l2; >> 360cae313702cd Paul Mackerras 2018-10-08 321 vcpu->arch.nested_vcpu_id = l2_hv.vcpu_token; >> 360cae313702cd Paul Mackerras 2018-10-08 322 vcpu->arch.regs = l2_regs; >> 360cae313702cd Paul Mackerras 2018-10-08 323 vcpu->arch.shregs.msr = vcpu->arch.regs.msr; >> 360cae313702cd Paul Mackerras 2018-10-08 324 mask = LPCR_DPFD | LPCR_ILE | LPCR_TC | LPCR_AIL | LPCR_LD | >> 360cae313702cd Paul Mackerras 2018-10-08 325 LPCR_LPES | LPCR_MER; >> 360cae313702cd Paul Mackerras 2018-10-08 326 lpcr = (vc->lpcr & ~mask) | (l2_hv.lpcr & mask); >> 73937deb4b2d7f Suraj Jitindar Singh 2018-10-08 327 sanitise_hv_regs(vcpu, &l2_hv); >> 360cae313702cd Paul Mackerras 2018-10-08 328 restore_hv_regs(vcpu, &l2_hv); >> 360cae313702cd Paul Mackerras 2018-10-08 329 >> 360cae313702cd Paul Mackerras 2018-10-08 330 vcpu->arch.ret = RESUME_GUEST; >> 360cae313702cd Paul Mackerras 2018-10-08 331 vcpu->arch.trap = 0; >> 360cae313702cd Paul Mackerras 2018-10-08 332 do { >> 360cae313702cd Paul Mackerras 2018-10-08 333 if (mftb() >= hdec_exp) { >> 360cae313702cd Paul Mackerras 2018-10-08 334 vcpu->arch.trap = BOOK3S_INTERRUPT_HV_DECREMENTER; >> 360cae313702cd Paul Mackerras 2018-10-08 335 r = RESUME_HOST; >> 360cae313702cd Paul Mackerras 2018-10-08 336 break; >> 360cae313702cd Paul Mackerras 2018-10-08 337 } >> 8c99d34578628b Tianjia Zhang 2020-04-27 338 r = kvmhv_run_single_vcpu(vcpu, hdec_exp, lpcr); >> 360cae313702cd Paul Mackerras 2018-10-08 339 } while (is_kvmppc_resume_guest(r)); >> 360cae313702cd Paul Mackerras 2018-10-08 340 >> 360cae313702cd Paul Mackerras 2018-10-08 341 /* save L2 state for return */ >> 360cae313702cd Paul Mackerras 2018-10-08 342 l2_regs = vcpu->arch.regs; >> 360cae313702cd Paul Mackerras 2018-10-08 343 l2_regs.msr = vcpu->arch.shregs.msr; >> 360cae313702cd Paul Mackerras 2018-10-08 344 delta_purr = vcpu->arch.purr - l2_hv.purr; >> 360cae313702cd Paul Mackerras 2018-10-08 345 delta_spurr = vcpu->arch.spurr - l2_hv.spurr; >> 360cae313702cd Paul Mackerras 2018-10-08 346 delta_ic = vcpu->arch.ic - l2_hv.ic; >> 360cae313702cd Paul Mackerras 2018-10-08 347 delta_vtb = vc->vtb - l2_hv.vtb; >> 360cae313702cd Paul Mackerras 2018-10-08 348 save_hv_return_state(vcpu, vcpu->arch.trap, &l2_hv); >> 360cae313702cd Paul Mackerras 2018-10-08 349 >> 360cae313702cd Paul Mackerras 2018-10-08 350 /* restore L1 state */ >> 360cae313702cd Paul Mackerras 2018-10-08 351 vcpu->arch.nested = NULL; >> 360cae313702cd Paul Mackerras 2018-10-08 352 vcpu->arch.regs = saved_l1_regs; >> 360cae313702cd Paul Mackerras 2018-10-08 353 vcpu->arch.shregs.msr = saved_l1_regs.msr & ~MSR_TS_MASK; >> 360cae313702cd Paul Mackerras 2018-10-08 354 /* set L1 MSR TS field according to L2 transaction state */ >> 360cae313702cd Paul Mackerras 2018-10-08 355 if (l2_regs.msr & MSR_TS_MASK) >> 360cae313702cd Paul Mackerras 2018-10-08 356 vcpu->arch.shregs.msr |= MSR_TS_S; >> 360cae313702cd Paul Mackerras 2018-10-08 357 vc->tb_offset = saved_l1_hv.tb_offset; >> 360cae313702cd Paul Mackerras 2018-10-08 358 restore_hv_regs(vcpu, &saved_l1_hv); >> 360cae313702cd Paul Mackerras 2018-10-08 359 vcpu->arch.purr += delta_purr; >> 360cae313702cd Paul Mackerras 2018-10-08 360 vcpu->arch.spurr += delta_spurr; >> 360cae313702cd Paul Mackerras 2018-10-08 361 vcpu->arch.ic += delta_ic; >> 360cae313702cd Paul Mackerras 2018-10-08 362 vc->vtb += delta_vtb; >> 360cae313702cd Paul Mackerras 2018-10-08 363 >> 360cae313702cd Paul Mackerras 2018-10-08 364 kvmhv_put_nested(l2); >> 360cae313702cd Paul Mackerras 2018-10-08 365 >> 360cae313702cd Paul Mackerras 2018-10-08 366 /* copy l2_hv_state and regs back to guest */ >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 367 if (kvmppc_need_byteswap(vcpu)) { >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 368 byteswap_hv_regs(&l2_hv); >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 369 byteswap_pt_regs(&l2_regs); >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 370 } >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 371 vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); >> afe75049303f75 Ravi Bangoria 2020-12-16 372 err = kvmhv_write_guest_state_and_regs(vcpu, &l2_hv, &l2_regs, >> afe75049303f75 Ravi Bangoria 2020-12-16 373 hv_ptr, regs_ptr); >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 374 srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); >> 360cae313702cd Paul Mackerras 2018-10-08 375 if (err) >> 360cae313702cd Paul Mackerras 2018-10-08 376 return H_AUTHORITY; >> 360cae313702cd Paul Mackerras 2018-10-08 377 >> 360cae313702cd Paul Mackerras 2018-10-08 378 if (r == -EINTR) >> 360cae313702cd Paul Mackerras 2018-10-08 379 return H_INTERRUPT; >> 360cae313702cd Paul Mackerras 2018-10-08 380 >> 873db2cd9a6d7f Suraj Jitindar Singh 2018-12-14 381 if (vcpu->mmio_needed) { >> 873db2cd9a6d7f Suraj Jitindar Singh 2018-12-14 382 kvmhv_nested_mmio_needed(vcpu, regs_ptr); >> 873db2cd9a6d7f Suraj Jitindar Singh 2018-12-14 383 return H_TOO_HARD; >> 873db2cd9a6d7f Suraj Jitindar Singh 2018-12-14 384 } >> 873db2cd9a6d7f Suraj Jitindar Singh 2018-12-14 385 >> 360cae313702cd Paul Mackerras 2018-10-08 386 return vcpu->arch.trap; >> 360cae313702cd Paul Mackerras 2018-10-08 387 } >> 360cae313702cd Paul Mackerras 2018-10-08 388 >> >> :::::: The code at line 264 was first introduced by commit >> :::::: 360cae313702cdd0b90f82c261a8302fecef030a KVM: PPC: Book3S HV: Nested guest entry via hypercall >> >> :::::: TO: Paul Mackerras >> :::::: CC: Michael Ellerman >> >> --- >> 0-DAY CI Kernel Test Service, Intel Corporation >> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org >> From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03C9EC48BE5 for ; Mon, 21 Jun 2021 05:54:01 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 02D466113C for ; Mon, 21 Jun 2021 05:53:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 02D466113C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4G7dxz1NXWz3bv4 for ; Mon, 21 Jun 2021 15:53:59 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=P5Wn0abp; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=198.145.29.99; helo=mail.kernel.org; envelope-from=nathan@kernel.org; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=P5Wn0abp; dkim-atps=neutral Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4G7dxQ6H8gz2yXj for ; Mon, 21 Jun 2021 15:53:30 +1000 (AEST) Received: by mail.kernel.org (Postfix) with ESMTPSA id 1B3B76113C; Mon, 21 Jun 2021 05:53:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624254806; bh=VNjmysMr5aFo5Y2ewZkvwCDsHp1Bte5+E7/g36fuzzU=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=P5Wn0abpDffObFsODQBb46AJG5uEv9KMlhwnpO5l3hywP10zpyQgChYxpIIvT6C+0 lIo0YRD1ngL1aAg252d8jh7E4Fdvn3Je8gTBRPMY0eyJ0HVzsZYrdXjOMBPrYR5juR 1cpMKVxm1MJEk99eC7lX/XYt77ZMMYExCYEwTr2vdNrtReY6oB1tmI7ApA4kpu/ue+ WQldb9mRpxM6zrO+/H7AtSpmfqkknVPQoc9/jGqChsLrnxefRVe4ZsvqzB6bjwOEbl xhiUYqIn2Vc6Yyi+ktmhCNjBNK1eQfkq4XSPDDbZBahco7TTJc4KsCJa4rdZbq6MEq hnUmFO4HxHgtQ== Subject: Re: arch/powerpc/kvm/book3s_hv_nested.c:264:6: error: stack frame size of 2304 bytes in function 'kvmhv_enter_nested_guest' To: Nicholas Piggin , Arnd Bergmann , kernel test robot References: <202104031853.vDT0Qjqj-lkp@intel.com> <1624232938.d90brlmh3p.astroid@bobo.none> From: Nathan Chancellor Message-ID: Date: Sun, 20 Jun 2021 22:53:22 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <1624232938.d90brlmh3p.astroid@bobo.none> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kbuild-all@lists.01.org, Kees Cook , clang-built-linux@googlegroups.com, linux-kernel@vger.kernel.org, kvm-ppc@vger.kernel.org, Linux Memory Management List , Andrew Morton , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On 6/20/2021 4:59 PM, Nicholas Piggin wrote: > Excerpts from kernel test robot's message of April 3, 2021 8:47 pm: >> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master >> head: d93a0d43e3d0ba9e19387be4dae4a8d5b175a8d7 >> commit: 97e4910232fa1f81e806aa60c25a0450276d99a2 linux/compiler-clang.h: define HAVE_BUILTIN_BSWAP* >> date: 3 weeks ago >> config: powerpc64-randconfig-r006-20210403 (attached as .config) >> compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 0fe8af94688aa03c01913c2001d6a1a911f42ce6) >> reproduce (this is a W=1 build): >> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross >> chmod +x ~/bin/make.cross >> # install powerpc64 cross compiling tool for clang build >> # apt-get install binutils-powerpc64-linux-gnu >> # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=97e4910232fa1f81e806aa60c25a0450276d99a2 >> git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git >> git fetch --no-tags linus master >> git checkout 97e4910232fa1f81e806aa60c25a0450276d99a2 >> # save the attached .config to linux build tree >> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64 >> >> If you fix the issue, kindly add following tag as appropriate >> Reported-by: kernel test robot >> >> All errors (new ones prefixed by >>): >> >>>> arch/powerpc/kvm/book3s_hv_nested.c:264:6: error: stack frame size of 2304 bytes in function 'kvmhv_enter_nested_guest' [-Werror,-Wframe-larger-than=] >> long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu) >> ^ >> 1 error generated. >> >> >> vim +/kvmhv_enter_nested_guest +264 arch/powerpc/kvm/book3s_hv_nested.c > > Not much changed here recently. It's not that big a concern because it's > only called in the KVM ioctl path, not in any deep IO paths or anything, > and doesn't recurse. Might be a bit of inlining or stack spilling put it > over the edge. It appears to be the fact that LLVM's PowerPC backend does not emit efficient byteswap assembly: https://github.com/ClangBuiltLinux/linux/issues/1292 https://bugs.llvm.org/show_bug.cgi?id=49610 > powerpc does make it an error though, would be good to avoid that so the > robot doesn't keep tripping over. Marking byteswap_pt_regs as 'noinline_for_stack' drastically reduces the stack usage. If that is an acceptable solution, I can send it along tomorrow. Cheers, Nathan > Thanks, > Nick > > >> >> afe75049303f75 Ravi Bangoria 2020-12-16 263 >> 360cae313702cd Paul Mackerras 2018-10-08 @264 long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu) >> 360cae313702cd Paul Mackerras 2018-10-08 265 { >> 360cae313702cd Paul Mackerras 2018-10-08 266 long int err, r; >> 360cae313702cd Paul Mackerras 2018-10-08 267 struct kvm_nested_guest *l2; >> 360cae313702cd Paul Mackerras 2018-10-08 268 struct pt_regs l2_regs, saved_l1_regs; >> afe75049303f75 Ravi Bangoria 2020-12-16 269 struct hv_guest_state l2_hv = {0}, saved_l1_hv; >> 360cae313702cd Paul Mackerras 2018-10-08 270 struct kvmppc_vcore *vc = vcpu->arch.vcore; >> 360cae313702cd Paul Mackerras 2018-10-08 271 u64 hv_ptr, regs_ptr; >> 360cae313702cd Paul Mackerras 2018-10-08 272 u64 hdec_exp; >> 360cae313702cd Paul Mackerras 2018-10-08 273 s64 delta_purr, delta_spurr, delta_ic, delta_vtb; >> 360cae313702cd Paul Mackerras 2018-10-08 274 u64 mask; >> 360cae313702cd Paul Mackerras 2018-10-08 275 unsigned long lpcr; >> 360cae313702cd Paul Mackerras 2018-10-08 276 >> 360cae313702cd Paul Mackerras 2018-10-08 277 if (vcpu->kvm->arch.l1_ptcr == 0) >> 360cae313702cd Paul Mackerras 2018-10-08 278 return H_NOT_AVAILABLE; >> 360cae313702cd Paul Mackerras 2018-10-08 279 >> 360cae313702cd Paul Mackerras 2018-10-08 280 /* copy parameters in */ >> 360cae313702cd Paul Mackerras 2018-10-08 281 hv_ptr = kvmppc_get_gpr(vcpu, 4); >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 282 regs_ptr = kvmppc_get_gpr(vcpu, 5); >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 283 vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); >> afe75049303f75 Ravi Bangoria 2020-12-16 284 err = kvmhv_read_guest_state_and_regs(vcpu, &l2_hv, &l2_regs, >> afe75049303f75 Ravi Bangoria 2020-12-16 285 hv_ptr, regs_ptr); >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 286 srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); >> 360cae313702cd Paul Mackerras 2018-10-08 287 if (err) >> 360cae313702cd Paul Mackerras 2018-10-08 288 return H_PARAMETER; >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 289 >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 290 if (kvmppc_need_byteswap(vcpu)) >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 291 byteswap_hv_regs(&l2_hv); >> afe75049303f75 Ravi Bangoria 2020-12-16 292 if (l2_hv.version > HV_GUEST_STATE_VERSION) >> 360cae313702cd Paul Mackerras 2018-10-08 293 return H_P2; >> 360cae313702cd Paul Mackerras 2018-10-08 294 >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 295 if (kvmppc_need_byteswap(vcpu)) >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 296 byteswap_pt_regs(&l2_regs); >> 9d0b048da788c1 Suraj Jitindar Singh 2018-10-08 297 if (l2_hv.vcpu_token >= NR_CPUS) >> 9d0b048da788c1 Suraj Jitindar Singh 2018-10-08 298 return H_PARAMETER; >> 9d0b048da788c1 Suraj Jitindar Singh 2018-10-08 299 >> 360cae313702cd Paul Mackerras 2018-10-08 300 /* translate lpid */ >> 360cae313702cd Paul Mackerras 2018-10-08 301 l2 = kvmhv_get_nested(vcpu->kvm, l2_hv.lpid, true); >> 360cae313702cd Paul Mackerras 2018-10-08 302 if (!l2) >> 360cae313702cd Paul Mackerras 2018-10-08 303 return H_PARAMETER; >> 360cae313702cd Paul Mackerras 2018-10-08 304 if (!l2->l1_gr_to_hr) { >> 360cae313702cd Paul Mackerras 2018-10-08 305 mutex_lock(&l2->tlb_lock); >> 360cae313702cd Paul Mackerras 2018-10-08 306 kvmhv_update_ptbl_cache(l2); >> 360cae313702cd Paul Mackerras 2018-10-08 307 mutex_unlock(&l2->tlb_lock); >> 360cae313702cd Paul Mackerras 2018-10-08 308 } >> 360cae313702cd Paul Mackerras 2018-10-08 309 >> 360cae313702cd Paul Mackerras 2018-10-08 310 /* save l1 values of things */ >> 360cae313702cd Paul Mackerras 2018-10-08 311 vcpu->arch.regs.msr = vcpu->arch.shregs.msr; >> 360cae313702cd Paul Mackerras 2018-10-08 312 saved_l1_regs = vcpu->arch.regs; >> 360cae313702cd Paul Mackerras 2018-10-08 313 kvmhv_save_hv_regs(vcpu, &saved_l1_hv); >> 360cae313702cd Paul Mackerras 2018-10-08 314 >> 360cae313702cd Paul Mackerras 2018-10-08 315 /* convert TB values/offsets to host (L0) values */ >> 360cae313702cd Paul Mackerras 2018-10-08 316 hdec_exp = l2_hv.hdec_expiry - vc->tb_offset; >> 360cae313702cd Paul Mackerras 2018-10-08 317 vc->tb_offset += l2_hv.tb_offset; >> 360cae313702cd Paul Mackerras 2018-10-08 318 >> 360cae313702cd Paul Mackerras 2018-10-08 319 /* set L1 state to L2 state */ >> 360cae313702cd Paul Mackerras 2018-10-08 320 vcpu->arch.nested = l2; >> 360cae313702cd Paul Mackerras 2018-10-08 321 vcpu->arch.nested_vcpu_id = l2_hv.vcpu_token; >> 360cae313702cd Paul Mackerras 2018-10-08 322 vcpu->arch.regs = l2_regs; >> 360cae313702cd Paul Mackerras 2018-10-08 323 vcpu->arch.shregs.msr = vcpu->arch.regs.msr; >> 360cae313702cd Paul Mackerras 2018-10-08 324 mask = LPCR_DPFD | LPCR_ILE | LPCR_TC | LPCR_AIL | LPCR_LD | >> 360cae313702cd Paul Mackerras 2018-10-08 325 LPCR_LPES | LPCR_MER; >> 360cae313702cd Paul Mackerras 2018-10-08 326 lpcr = (vc->lpcr & ~mask) | (l2_hv.lpcr & mask); >> 73937deb4b2d7f Suraj Jitindar Singh 2018-10-08 327 sanitise_hv_regs(vcpu, &l2_hv); >> 360cae313702cd Paul Mackerras 2018-10-08 328 restore_hv_regs(vcpu, &l2_hv); >> 360cae313702cd Paul Mackerras 2018-10-08 329 >> 360cae313702cd Paul Mackerras 2018-10-08 330 vcpu->arch.ret = RESUME_GUEST; >> 360cae313702cd Paul Mackerras 2018-10-08 331 vcpu->arch.trap = 0; >> 360cae313702cd Paul Mackerras 2018-10-08 332 do { >> 360cae313702cd Paul Mackerras 2018-10-08 333 if (mftb() >= hdec_exp) { >> 360cae313702cd Paul Mackerras 2018-10-08 334 vcpu->arch.trap = BOOK3S_INTERRUPT_HV_DECREMENTER; >> 360cae313702cd Paul Mackerras 2018-10-08 335 r = RESUME_HOST; >> 360cae313702cd Paul Mackerras 2018-10-08 336 break; >> 360cae313702cd Paul Mackerras 2018-10-08 337 } >> 8c99d34578628b Tianjia Zhang 2020-04-27 338 r = kvmhv_run_single_vcpu(vcpu, hdec_exp, lpcr); >> 360cae313702cd Paul Mackerras 2018-10-08 339 } while (is_kvmppc_resume_guest(r)); >> 360cae313702cd Paul Mackerras 2018-10-08 340 >> 360cae313702cd Paul Mackerras 2018-10-08 341 /* save L2 state for return */ >> 360cae313702cd Paul Mackerras 2018-10-08 342 l2_regs = vcpu->arch.regs; >> 360cae313702cd Paul Mackerras 2018-10-08 343 l2_regs.msr = vcpu->arch.shregs.msr; >> 360cae313702cd Paul Mackerras 2018-10-08 344 delta_purr = vcpu->arch.purr - l2_hv.purr; >> 360cae313702cd Paul Mackerras 2018-10-08 345 delta_spurr = vcpu->arch.spurr - l2_hv.spurr; >> 360cae313702cd Paul Mackerras 2018-10-08 346 delta_ic = vcpu->arch.ic - l2_hv.ic; >> 360cae313702cd Paul Mackerras 2018-10-08 347 delta_vtb = vc->vtb - l2_hv.vtb; >> 360cae313702cd Paul Mackerras 2018-10-08 348 save_hv_return_state(vcpu, vcpu->arch.trap, &l2_hv); >> 360cae313702cd Paul Mackerras 2018-10-08 349 >> 360cae313702cd Paul Mackerras 2018-10-08 350 /* restore L1 state */ >> 360cae313702cd Paul Mackerras 2018-10-08 351 vcpu->arch.nested = NULL; >> 360cae313702cd Paul Mackerras 2018-10-08 352 vcpu->arch.regs = saved_l1_regs; >> 360cae313702cd Paul Mackerras 2018-10-08 353 vcpu->arch.shregs.msr = saved_l1_regs.msr & ~MSR_TS_MASK; >> 360cae313702cd Paul Mackerras 2018-10-08 354 /* set L1 MSR TS field according to L2 transaction state */ >> 360cae313702cd Paul Mackerras 2018-10-08 355 if (l2_regs.msr & MSR_TS_MASK) >> 360cae313702cd Paul Mackerras 2018-10-08 356 vcpu->arch.shregs.msr |= MSR_TS_S; >> 360cae313702cd Paul Mackerras 2018-10-08 357 vc->tb_offset = saved_l1_hv.tb_offset; >> 360cae313702cd Paul Mackerras 2018-10-08 358 restore_hv_regs(vcpu, &saved_l1_hv); >> 360cae313702cd Paul Mackerras 2018-10-08 359 vcpu->arch.purr += delta_purr; >> 360cae313702cd Paul Mackerras 2018-10-08 360 vcpu->arch.spurr += delta_spurr; >> 360cae313702cd Paul Mackerras 2018-10-08 361 vcpu->arch.ic += delta_ic; >> 360cae313702cd Paul Mackerras 2018-10-08 362 vc->vtb += delta_vtb; >> 360cae313702cd Paul Mackerras 2018-10-08 363 >> 360cae313702cd Paul Mackerras 2018-10-08 364 kvmhv_put_nested(l2); >> 360cae313702cd Paul Mackerras 2018-10-08 365 >> 360cae313702cd Paul Mackerras 2018-10-08 366 /* copy l2_hv_state and regs back to guest */ >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 367 if (kvmppc_need_byteswap(vcpu)) { >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 368 byteswap_hv_regs(&l2_hv); >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 369 byteswap_pt_regs(&l2_regs); >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 370 } >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 371 vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); >> afe75049303f75 Ravi Bangoria 2020-12-16 372 err = kvmhv_write_guest_state_and_regs(vcpu, &l2_hv, &l2_regs, >> afe75049303f75 Ravi Bangoria 2020-12-16 373 hv_ptr, regs_ptr); >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 374 srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); >> 360cae313702cd Paul Mackerras 2018-10-08 375 if (err) >> 360cae313702cd Paul Mackerras 2018-10-08 376 return H_AUTHORITY; >> 360cae313702cd Paul Mackerras 2018-10-08 377 >> 360cae313702cd Paul Mackerras 2018-10-08 378 if (r == -EINTR) >> 360cae313702cd Paul Mackerras 2018-10-08 379 return H_INTERRUPT; >> 360cae313702cd Paul Mackerras 2018-10-08 380 >> 873db2cd9a6d7f Suraj Jitindar Singh 2018-12-14 381 if (vcpu->mmio_needed) { >> 873db2cd9a6d7f Suraj Jitindar Singh 2018-12-14 382 kvmhv_nested_mmio_needed(vcpu, regs_ptr); >> 873db2cd9a6d7f Suraj Jitindar Singh 2018-12-14 383 return H_TOO_HARD; >> 873db2cd9a6d7f Suraj Jitindar Singh 2018-12-14 384 } >> 873db2cd9a6d7f Suraj Jitindar Singh 2018-12-14 385 >> 360cae313702cd Paul Mackerras 2018-10-08 386 return vcpu->arch.trap; >> 360cae313702cd Paul Mackerras 2018-10-08 387 } >> 360cae313702cd Paul Mackerras 2018-10-08 388 >> >> :::::: The code at line 264 was first introduced by commit >> :::::: 360cae313702cdd0b90f82c261a8302fecef030a KVM: PPC: Book3S HV: Nested guest entry via hypercall >> >> :::::: TO: Paul Mackerras >> :::::: CC: Michael Ellerman >> >> --- >> 0-DAY CI Kernel Test Service, Intel Corporation >> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org >> From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============8419010947016531976==" MIME-Version: 1.0 From: Nathan Chancellor To: kbuild-all@lists.01.org Subject: Re: arch/powerpc/kvm/book3s_hv_nested.c:264:6: error: stack frame size of 2304 bytes in function 'kvmhv_enter_nested_guest' Date: Sun, 20 Jun 2021 22:53:22 -0700 Message-ID: In-Reply-To: <1624232938.d90brlmh3p.astroid@bobo.none> List-Id: --===============8419010947016531976== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable On 6/20/2021 4:59 PM, Nicholas Piggin wrote: > Excerpts from kernel test robot's message of April 3, 2021 8:47 pm: >> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.g= it master >> head: d93a0d43e3d0ba9e19387be4dae4a8d5b175a8d7 >> commit: 97e4910232fa1f81e806aa60c25a0450276d99a2 linux/compiler-clang.h:= define HAVE_BUILTIN_BSWAP* >> date: 3 weeks ago >> config: powerpc64-randconfig-r006-20210403 (attached as .config) >> compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 0fe= 8af94688aa03c01913c2001d6a1a911f42ce6) >> reproduce (this is a W=3D1 build): >> wget https://raw.githubusercontent.com/intel/lkp-tests/master/s= bin/make.cross -O ~/bin/make.cross >> chmod +x ~/bin/make.cross >> # install powerpc64 cross compiling tool for clang build >> # apt-get install binutils-powerpc64-linux-gnu >> # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linu= x.git/commit/?id=3D97e4910232fa1f81e806aa60c25a0450276d99a2 >> git remote add linus https://git.kernel.org/pub/scm/linux/kerne= l/git/torvalds/linux.git >> git fetch --no-tags linus master >> git checkout 97e4910232fa1f81e806aa60c25a0450276d99a2 >> # save the attached .config to linux build tree >> COMPILER_INSTALL_PATH=3D$HOME/0day COMPILER=3Dclang make.cross = ARCH=3Dpowerpc64 >> >> If you fix the issue, kindly add following tag as appropriate >> Reported-by: kernel test robot >> >> All errors (new ones prefixed by >>): >> >>>> arch/powerpc/kvm/book3s_hv_nested.c:264:6: error: stack frame size of = 2304 bytes in function 'kvmhv_enter_nested_guest' [-Werror,-Wframe-larger-t= han=3D] >> long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu) >> ^ >> 1 error generated. >> >> >> vim +/kvmhv_enter_nested_guest +264 arch/powerpc/kvm/book3s_hv_nested.c > = > Not much changed here recently. It's not that big a concern because it's > only called in the KVM ioctl path, not in any deep IO paths or anything, > and doesn't recurse. Might be a bit of inlining or stack spilling put it > over the edge. It appears to be the fact that LLVM's PowerPC backend does not emit = efficient byteswap assembly: https://github.com/ClangBuiltLinux/linux/issues/1292 https://bugs.llvm.org/show_bug.cgi?id=3D49610 > powerpc does make it an error though, would be good to avoid that so the > robot doesn't keep tripping over. Marking byteswap_pt_regs as 'noinline_for_stack' drastically reduces the = stack usage. If that is an acceptable solution, I can send it along = tomorrow. Cheers, Nathan > Thanks, > Nick > = > = >> >> afe75049303f75 Ravi Bangoria 2020-12-16 263 >> 360cae313702cd Paul Mackerras 2018-10-08 @264 long kvmhv_enter_ne= sted_guest(struct kvm_vcpu *vcpu) >> 360cae313702cd Paul Mackerras 2018-10-08 265 { >> 360cae313702cd Paul Mackerras 2018-10-08 266 long int err, r; >> 360cae313702cd Paul Mackerras 2018-10-08 267 struct kvm_nested_= guest *l2; >> 360cae313702cd Paul Mackerras 2018-10-08 268 struct pt_regs l2_= regs, saved_l1_regs; >> afe75049303f75 Ravi Bangoria 2020-12-16 269 struct hv_guest_st= ate l2_hv =3D {0}, saved_l1_hv; >> 360cae313702cd Paul Mackerras 2018-10-08 270 struct kvmppc_vcor= e *vc =3D vcpu->arch.vcore; >> 360cae313702cd Paul Mackerras 2018-10-08 271 u64 hv_ptr, regs_p= tr; >> 360cae313702cd Paul Mackerras 2018-10-08 272 u64 hdec_exp; >> 360cae313702cd Paul Mackerras 2018-10-08 273 s64 delta_purr, de= lta_spurr, delta_ic, delta_vtb; >> 360cae313702cd Paul Mackerras 2018-10-08 274 u64 mask; >> 360cae313702cd Paul Mackerras 2018-10-08 275 unsigned long lpcr; >> 360cae313702cd Paul Mackerras 2018-10-08 276 >> 360cae313702cd Paul Mackerras 2018-10-08 277 if (vcpu->kvm->arc= h.l1_ptcr =3D=3D 0) >> 360cae313702cd Paul Mackerras 2018-10-08 278 return H_NOT_AVAI= LABLE; >> 360cae313702cd Paul Mackerras 2018-10-08 279 >> 360cae313702cd Paul Mackerras 2018-10-08 280 /* copy parameters= in */ >> 360cae313702cd Paul Mackerras 2018-10-08 281 hv_ptr =3D kvmppc_= get_gpr(vcpu, 4); >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 282 regs_ptr =3D kvmpp= c_get_gpr(vcpu, 5); >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 283 vcpu->srcu_idx =3D= srcu_read_lock(&vcpu->kvm->srcu); >> afe75049303f75 Ravi Bangoria 2020-12-16 284 err =3D kvmhv_read= _guest_state_and_regs(vcpu, &l2_hv, &l2_regs, >> afe75049303f75 Ravi Bangoria 2020-12-16 285 hv_ptr, = regs_ptr); >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 286 srcu_read_unlock(&= vcpu->kvm->srcu, vcpu->srcu_idx); >> 360cae313702cd Paul Mackerras 2018-10-08 287 if (err) >> 360cae313702cd Paul Mackerras 2018-10-08 288 return H_PARAMETE= R; >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 289 >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 290 if (kvmppc_need_by= teswap(vcpu)) >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 291 byteswap_hv_regs(= &l2_hv); >> afe75049303f75 Ravi Bangoria 2020-12-16 292 if (l2_hv.version = > HV_GUEST_STATE_VERSION) >> 360cae313702cd Paul Mackerras 2018-10-08 293 return H_P2; >> 360cae313702cd Paul Mackerras 2018-10-08 294 >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 295 if (kvmppc_need_by= teswap(vcpu)) >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 296 byteswap_pt_regs(= &l2_regs); >> 9d0b048da788c1 Suraj Jitindar Singh 2018-10-08 297 if (l2_hv.vcpu_tok= en >=3D NR_CPUS) >> 9d0b048da788c1 Suraj Jitindar Singh 2018-10-08 298 return H_PARAMETE= R; >> 9d0b048da788c1 Suraj Jitindar Singh 2018-10-08 299 >> 360cae313702cd Paul Mackerras 2018-10-08 300 /* translate lpid = */ >> 360cae313702cd Paul Mackerras 2018-10-08 301 l2 =3D kvmhv_get_n= ested(vcpu->kvm, l2_hv.lpid, true); >> 360cae313702cd Paul Mackerras 2018-10-08 302 if (!l2) >> 360cae313702cd Paul Mackerras 2018-10-08 303 return H_PARAMETE= R; >> 360cae313702cd Paul Mackerras 2018-10-08 304 if (!l2->l1_gr_to_= hr) { >> 360cae313702cd Paul Mackerras 2018-10-08 305 mutex_lock(&l2->t= lb_lock); >> 360cae313702cd Paul Mackerras 2018-10-08 306 kvmhv_update_ptbl= _cache(l2); >> 360cae313702cd Paul Mackerras 2018-10-08 307 mutex_unlock(&l2-= >tlb_lock); >> 360cae313702cd Paul Mackerras 2018-10-08 308 } >> 360cae313702cd Paul Mackerras 2018-10-08 309 >> 360cae313702cd Paul Mackerras 2018-10-08 310 /* save l1 values = of things */ >> 360cae313702cd Paul Mackerras 2018-10-08 311 vcpu->arch.regs.ms= r =3D vcpu->arch.shregs.msr; >> 360cae313702cd Paul Mackerras 2018-10-08 312 saved_l1_regs =3D = vcpu->arch.regs; >> 360cae313702cd Paul Mackerras 2018-10-08 313 kvmhv_save_hv_regs= (vcpu, &saved_l1_hv); >> 360cae313702cd Paul Mackerras 2018-10-08 314 >> 360cae313702cd Paul Mackerras 2018-10-08 315 /* convert TB valu= es/offsets to host (L0) values */ >> 360cae313702cd Paul Mackerras 2018-10-08 316 hdec_exp =3D l2_hv= .hdec_expiry - vc->tb_offset; >> 360cae313702cd Paul Mackerras 2018-10-08 317 vc->tb_offset +=3D= l2_hv.tb_offset; >> 360cae313702cd Paul Mackerras 2018-10-08 318 >> 360cae313702cd Paul Mackerras 2018-10-08 319 /* set L1 state to= L2 state */ >> 360cae313702cd Paul Mackerras 2018-10-08 320 vcpu->arch.nested = =3D l2; >> 360cae313702cd Paul Mackerras 2018-10-08 321 vcpu->arch.nested_= vcpu_id =3D l2_hv.vcpu_token; >> 360cae313702cd Paul Mackerras 2018-10-08 322 vcpu->arch.regs = =3D l2_regs; >> 360cae313702cd Paul Mackerras 2018-10-08 323 vcpu->arch.shregs.= msr =3D vcpu->arch.regs.msr; >> 360cae313702cd Paul Mackerras 2018-10-08 324 mask =3D LPCR_DPFD= | LPCR_ILE | LPCR_TC | LPCR_AIL | LPCR_LD | >> 360cae313702cd Paul Mackerras 2018-10-08 325 LPCR_LPES | LPCR_= MER; >> 360cae313702cd Paul Mackerras 2018-10-08 326 lpcr =3D (vc->lpcr= & ~mask) | (l2_hv.lpcr & mask); >> 73937deb4b2d7f Suraj Jitindar Singh 2018-10-08 327 sanitise_hv_regs(v= cpu, &l2_hv); >> 360cae313702cd Paul Mackerras 2018-10-08 328 restore_hv_regs(vc= pu, &l2_hv); >> 360cae313702cd Paul Mackerras 2018-10-08 329 >> 360cae313702cd Paul Mackerras 2018-10-08 330 vcpu->arch.ret =3D= RESUME_GUEST; >> 360cae313702cd Paul Mackerras 2018-10-08 331 vcpu->arch.trap = =3D 0; >> 360cae313702cd Paul Mackerras 2018-10-08 332 do { >> 360cae313702cd Paul Mackerras 2018-10-08 333 if (mftb() >=3D h= dec_exp) { >> 360cae313702cd Paul Mackerras 2018-10-08 334 vcpu->arch.trap = =3D BOOK3S_INTERRUPT_HV_DECREMENTER; >> 360cae313702cd Paul Mackerras 2018-10-08 335 r =3D RESUME_HOS= T; >> 360cae313702cd Paul Mackerras 2018-10-08 336 break; >> 360cae313702cd Paul Mackerras 2018-10-08 337 } >> 8c99d34578628b Tianjia Zhang 2020-04-27 338 r =3D kvmhv_run_s= ingle_vcpu(vcpu, hdec_exp, lpcr); >> 360cae313702cd Paul Mackerras 2018-10-08 339 } while (is_kvmppc= _resume_guest(r)); >> 360cae313702cd Paul Mackerras 2018-10-08 340 >> 360cae313702cd Paul Mackerras 2018-10-08 341 /* save L2 state f= or return */ >> 360cae313702cd Paul Mackerras 2018-10-08 342 l2_regs =3D vcpu->= arch.regs; >> 360cae313702cd Paul Mackerras 2018-10-08 343 l2_regs.msr =3D vc= pu->arch.shregs.msr; >> 360cae313702cd Paul Mackerras 2018-10-08 344 delta_purr =3D vcp= u->arch.purr - l2_hv.purr; >> 360cae313702cd Paul Mackerras 2018-10-08 345 delta_spurr =3D vc= pu->arch.spurr - l2_hv.spurr; >> 360cae313702cd Paul Mackerras 2018-10-08 346 delta_ic =3D vcpu-= >arch.ic - l2_hv.ic; >> 360cae313702cd Paul Mackerras 2018-10-08 347 delta_vtb =3D vc->= vtb - l2_hv.vtb; >> 360cae313702cd Paul Mackerras 2018-10-08 348 save_hv_return_sta= te(vcpu, vcpu->arch.trap, &l2_hv); >> 360cae313702cd Paul Mackerras 2018-10-08 349 >> 360cae313702cd Paul Mackerras 2018-10-08 350 /* restore L1 stat= e */ >> 360cae313702cd Paul Mackerras 2018-10-08 351 vcpu->arch.nested = =3D NULL; >> 360cae313702cd Paul Mackerras 2018-10-08 352 vcpu->arch.regs = =3D saved_l1_regs; >> 360cae313702cd Paul Mackerras 2018-10-08 353 vcpu->arch.shregs.= msr =3D saved_l1_regs.msr & ~MSR_TS_MASK; >> 360cae313702cd Paul Mackerras 2018-10-08 354 /* set L1 MSR TS f= ield according to L2 transaction state */ >> 360cae313702cd Paul Mackerras 2018-10-08 355 if (l2_regs.msr & = MSR_TS_MASK) >> 360cae313702cd Paul Mackerras 2018-10-08 356 vcpu->arch.shregs= .msr |=3D MSR_TS_S; >> 360cae313702cd Paul Mackerras 2018-10-08 357 vc->tb_offset =3D = saved_l1_hv.tb_offset; >> 360cae313702cd Paul Mackerras 2018-10-08 358 restore_hv_regs(vc= pu, &saved_l1_hv); >> 360cae313702cd Paul Mackerras 2018-10-08 359 vcpu->arch.purr += =3D delta_purr; >> 360cae313702cd Paul Mackerras 2018-10-08 360 vcpu->arch.spurr += =3D delta_spurr; >> 360cae313702cd Paul Mackerras 2018-10-08 361 vcpu->arch.ic +=3D= delta_ic; >> 360cae313702cd Paul Mackerras 2018-10-08 362 vc->vtb +=3D delta= _vtb; >> 360cae313702cd Paul Mackerras 2018-10-08 363 >> 360cae313702cd Paul Mackerras 2018-10-08 364 kvmhv_put_nested(l= 2); >> 360cae313702cd Paul Mackerras 2018-10-08 365 >> 360cae313702cd Paul Mackerras 2018-10-08 366 /* copy l2_hv_stat= e and regs back to guest */ >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 367 if (kvmppc_need_by= teswap(vcpu)) { >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 368 byteswap_hv_regs(= &l2_hv); >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 369 byteswap_pt_regs(= &l2_regs); >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 370 } >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 371 vcpu->srcu_idx =3D= srcu_read_lock(&vcpu->kvm->srcu); >> afe75049303f75 Ravi Bangoria 2020-12-16 372 err =3D kvmhv_writ= e_guest_state_and_regs(vcpu, &l2_hv, &l2_regs, >> afe75049303f75 Ravi Bangoria 2020-12-16 373 hv_ptr,= regs_ptr); >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 374 srcu_read_unlock(&= vcpu->kvm->srcu, vcpu->srcu_idx); >> 360cae313702cd Paul Mackerras 2018-10-08 375 if (err) >> 360cae313702cd Paul Mackerras 2018-10-08 376 return H_AUTHORIT= Y; >> 360cae313702cd Paul Mackerras 2018-10-08 377 >> 360cae313702cd Paul Mackerras 2018-10-08 378 if (r =3D=3D -EINT= R) >> 360cae313702cd Paul Mackerras 2018-10-08 379 return H_INTERRUP= T; >> 360cae313702cd Paul Mackerras 2018-10-08 380 >> 873db2cd9a6d7f Suraj Jitindar Singh 2018-12-14 381 if (vcpu->mmio_nee= ded) { >> 873db2cd9a6d7f Suraj Jitindar Singh 2018-12-14 382 kvmhv_nested_mmio= _needed(vcpu, regs_ptr); >> 873db2cd9a6d7f Suraj Jitindar Singh 2018-12-14 383 return H_TOO_HARD; >> 873db2cd9a6d7f Suraj Jitindar Singh 2018-12-14 384 } >> 873db2cd9a6d7f Suraj Jitindar Singh 2018-12-14 385 >> 360cae313702cd Paul Mackerras 2018-10-08 386 return vcpu->arch.= trap; >> 360cae313702cd Paul Mackerras 2018-10-08 387 } >> 360cae313702cd Paul Mackerras 2018-10-08 388 >> >> :::::: The code at line 264 was first introduced by commit >> :::::: 360cae313702cdd0b90f82c261a8302fecef030a KVM: PPC: Book3S HV: Nes= ted guest entry via hypercall >> >> :::::: TO: Paul Mackerras >> :::::: CC: Michael Ellerman >> >> --- >> 0-DAY CI Kernel Test Service, Intel Corporation >> https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org >> --===============8419010947016531976==-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nathan Chancellor Date: Mon, 21 Jun 2021 05:53:22 +0000 Subject: Re: arch/powerpc/kvm/book3s_hv_nested.c:264:6: error: stack frame size of 2304 bytes in function 'kv Message-Id: List-Id: References: <202104031853.vDT0Qjqj-lkp@intel.com> <1624232938.d90brlmh3p.astroid@bobo.none> In-Reply-To: <1624232938.d90brlmh3p.astroid@bobo.none> MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable To: Nicholas Piggin , Arnd Bergmann , kernel test robot Cc: Andrew Morton , clang-built-linux@googlegroups.com, kbuild-all@lists.01.org, Kees Cook , linux-kernel@vger.kernel.org, Linux Memory Management List , linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org On 6/20/2021 4:59 PM, Nicholas Piggin wrote: > Excerpts from kernel test robot's message of April 3, 2021 8:47 pm: >> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.g= it master >> head: d93a0d43e3d0ba9e19387be4dae4a8d5b175a8d7 >> commit: 97e4910232fa1f81e806aa60c25a0450276d99a2 linux/compiler-clang.h:= define HAVE_BUILTIN_BSWAP* >> date: 3 weeks ago >> config: powerpc64-randconfig-r006-20210403 (attached as .config) >> compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 0fe= 8af94688aa03c01913c2001d6a1a911f42ce6) >> reproduce (this is a W=3D1 build): >> wget https://raw.githubusercontent.com/intel/lkp-tests/master/s= bin/make.cross -O ~/bin/make.cross >> chmod +x ~/bin/make.cross >> # install powerpc64 cross compiling tool for clang build >> # apt-get install binutils-powerpc64-linux-gnu >> # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linu= x.git/commit/?id=97e4910232fa1f81e806aa60c25a0450276d99a2 >> git remote add linus https://git.kernel.org/pub/scm/linux/kerne= l/git/torvalds/linux.git >> git fetch --no-tags linus master >> git checkout 97e4910232fa1f81e806aa60c25a0450276d99a2 >> # save the attached .config to linux build tree >> COMPILER_INSTALL_PATH=3D$HOME/0day COMPILER=3Dclang make.cross = ARCH=3Dpowerpc64 >> >> If you fix the issue, kindly add following tag as appropriate >> Reported-by: kernel test robot >> >> All errors (new ones prefixed by >>): >> >>>> arch/powerpc/kvm/book3s_hv_nested.c:264:6: error: stack frame size of = 2304 bytes in function 'kvmhv_enter_nested_guest' [-Werror,-Wframe-larger-t= han=3D] >> long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu) >> ^ >> 1 error generated. >> >> >> vim +/kvmhv_enter_nested_guest +264 arch/powerpc/kvm/book3s_hv_nested.c >=20 > Not much changed here recently. It's not that big a concern because it's > only called in the KVM ioctl path, not in any deep IO paths or anything, > and doesn't recurse. Might be a bit of inlining or stack spilling put it > over the edge. It appears to be the fact that LLVM's PowerPC backend does not emit=20 efficient byteswap assembly: https://github.com/ClangBuiltLinux/linux/issues/1292 https://bugs.llvm.org/show_bug.cgi?idI610 > powerpc does make it an error though, would be good to avoid that so the > robot doesn't keep tripping over. Marking byteswap_pt_regs as 'noinline_for_stack' drastically reduces the=20 stack usage. If that is an acceptable solution, I can send it along=20 tomorrow. Cheers, Nathan > Thanks, > Nick >=20 >=20 >> >> afe75049303f75 Ravi Bangoria 2020-12-16 263 >> 360cae313702cd Paul Mackerras 2018-10-08 @264 long kvmhv_enter_ne= sted_guest(struct kvm_vcpu *vcpu) >> 360cae313702cd Paul Mackerras 2018-10-08 265 { >> 360cae313702cd Paul Mackerras 2018-10-08 266 long int err, r; >> 360cae313702cd Paul Mackerras 2018-10-08 267 struct kvm_nested_= guest *l2; >> 360cae313702cd Paul Mackerras 2018-10-08 268 struct pt_regs l2_= regs, saved_l1_regs; >> afe75049303f75 Ravi Bangoria 2020-12-16 269 struct hv_guest_st= ate l2_hv =3D {0}, saved_l1_hv; >> 360cae313702cd Paul Mackerras 2018-10-08 270 struct kvmppc_vcor= e *vc =3D vcpu->arch.vcore; >> 360cae313702cd Paul Mackerras 2018-10-08 271 u64 hv_ptr, regs_p= tr; >> 360cae313702cd Paul Mackerras 2018-10-08 272 u64 hdec_exp; >> 360cae313702cd Paul Mackerras 2018-10-08 273 s64 delta_purr, de= lta_spurr, delta_ic, delta_vtb; >> 360cae313702cd Paul Mackerras 2018-10-08 274 u64 mask; >> 360cae313702cd Paul Mackerras 2018-10-08 275 unsigned long lpcr; >> 360cae313702cd Paul Mackerras 2018-10-08 276 >> 360cae313702cd Paul Mackerras 2018-10-08 277 if (vcpu->kvm->arc= h.l1_ptcr =3D 0) >> 360cae313702cd Paul Mackerras 2018-10-08 278 return H_NOT_AVAI= LABLE; >> 360cae313702cd Paul Mackerras 2018-10-08 279 >> 360cae313702cd Paul Mackerras 2018-10-08 280 /* copy parameters= in */ >> 360cae313702cd Paul Mackerras 2018-10-08 281 hv_ptr =3D kvmppc_= get_gpr(vcpu, 4); >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 282 regs_ptr =3D kvmpp= c_get_gpr(vcpu, 5); >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 283 vcpu->srcu_idx =3D= srcu_read_lock(&vcpu->kvm->srcu); >> afe75049303f75 Ravi Bangoria 2020-12-16 284 err =3D kvmhv_read= _guest_state_and_regs(vcpu, &l2_hv, &l2_regs, >> afe75049303f75 Ravi Bangoria 2020-12-16 285 hv_ptr, = regs_ptr); >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 286 srcu_read_unlock(&= vcpu->kvm->srcu, vcpu->srcu_idx); >> 360cae313702cd Paul Mackerras 2018-10-08 287 if (err) >> 360cae313702cd Paul Mackerras 2018-10-08 288 return H_PARAMETE= R; >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 289 >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 290 if (kvmppc_need_by= teswap(vcpu)) >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 291 byteswap_hv_regs(= &l2_hv); >> afe75049303f75 Ravi Bangoria 2020-12-16 292 if (l2_hv.version = > HV_GUEST_STATE_VERSION) >> 360cae313702cd Paul Mackerras 2018-10-08 293 return H_P2; >> 360cae313702cd Paul Mackerras 2018-10-08 294 >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 295 if (kvmppc_need_by= teswap(vcpu)) >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 296 byteswap_pt_regs(= &l2_regs); >> 9d0b048da788c1 Suraj Jitindar Singh 2018-10-08 297 if (l2_hv.vcpu_tok= en >=3D NR_CPUS) >> 9d0b048da788c1 Suraj Jitindar Singh 2018-10-08 298 return H_PARAMETE= R; >> 9d0b048da788c1 Suraj Jitindar Singh 2018-10-08 299 >> 360cae313702cd Paul Mackerras 2018-10-08 300 /* translate lpid = */ >> 360cae313702cd Paul Mackerras 2018-10-08 301 l2 =3D kvmhv_get_n= ested(vcpu->kvm, l2_hv.lpid, true); >> 360cae313702cd Paul Mackerras 2018-10-08 302 if (!l2) >> 360cae313702cd Paul Mackerras 2018-10-08 303 return H_PARAMETE= R; >> 360cae313702cd Paul Mackerras 2018-10-08 304 if (!l2->l1_gr_to_= hr) { >> 360cae313702cd Paul Mackerras 2018-10-08 305 mutex_lock(&l2->t= lb_lock); >> 360cae313702cd Paul Mackerras 2018-10-08 306 kvmhv_update_ptbl= _cache(l2); >> 360cae313702cd Paul Mackerras 2018-10-08 307 mutex_unlock(&l2-= >tlb_lock); >> 360cae313702cd Paul Mackerras 2018-10-08 308 } >> 360cae313702cd Paul Mackerras 2018-10-08 309 >> 360cae313702cd Paul Mackerras 2018-10-08 310 /* save l1 values = of things */ >> 360cae313702cd Paul Mackerras 2018-10-08 311 vcpu->arch.regs.ms= r =3D vcpu->arch.shregs.msr; >> 360cae313702cd Paul Mackerras 2018-10-08 312 saved_l1_regs =3D = vcpu->arch.regs; >> 360cae313702cd Paul Mackerras 2018-10-08 313 kvmhv_save_hv_regs= (vcpu, &saved_l1_hv); >> 360cae313702cd Paul Mackerras 2018-10-08 314 >> 360cae313702cd Paul Mackerras 2018-10-08 315 /* convert TB valu= es/offsets to host (L0) values */ >> 360cae313702cd Paul Mackerras 2018-10-08 316 hdec_exp =3D l2_hv= .hdec_expiry - vc->tb_offset; >> 360cae313702cd Paul Mackerras 2018-10-08 317 vc->tb_offset +=3D= l2_hv.tb_offset; >> 360cae313702cd Paul Mackerras 2018-10-08 318 >> 360cae313702cd Paul Mackerras 2018-10-08 319 /* set L1 state to= L2 state */ >> 360cae313702cd Paul Mackerras 2018-10-08 320 vcpu->arch.nested = =3D l2; >> 360cae313702cd Paul Mackerras 2018-10-08 321 vcpu->arch.nested_= vcpu_id =3D l2_hv.vcpu_token; >> 360cae313702cd Paul Mackerras 2018-10-08 322 vcpu->arch.regs = =3D l2_regs; >> 360cae313702cd Paul Mackerras 2018-10-08 323 vcpu->arch.shregs.= msr =3D vcpu->arch.regs.msr; >> 360cae313702cd Paul Mackerras 2018-10-08 324 mask =3D LPCR_DPFD= | LPCR_ILE | LPCR_TC | LPCR_AIL | LPCR_LD | >> 360cae313702cd Paul Mackerras 2018-10-08 325 LPCR_LPES | LPCR_= MER; >> 360cae313702cd Paul Mackerras 2018-10-08 326 lpcr =3D (vc->lpcr= & ~mask) | (l2_hv.lpcr & mask); >> 73937deb4b2d7f Suraj Jitindar Singh 2018-10-08 327 sanitise_hv_regs(v= cpu, &l2_hv); >> 360cae313702cd Paul Mackerras 2018-10-08 328 restore_hv_regs(vc= pu, &l2_hv); >> 360cae313702cd Paul Mackerras 2018-10-08 329 >> 360cae313702cd Paul Mackerras 2018-10-08 330 vcpu->arch.ret =3D= RESUME_GUEST; >> 360cae313702cd Paul Mackerras 2018-10-08 331 vcpu->arch.trap = =3D 0; >> 360cae313702cd Paul Mackerras 2018-10-08 332 do { >> 360cae313702cd Paul Mackerras 2018-10-08 333 if (mftb() >=3D h= dec_exp) { >> 360cae313702cd Paul Mackerras 2018-10-08 334 vcpu->arch.trap = =3D BOOK3S_INTERRUPT_HV_DECREMENTER; >> 360cae313702cd Paul Mackerras 2018-10-08 335 r =3D RESUME_HOS= T; >> 360cae313702cd Paul Mackerras 2018-10-08 336 break; >> 360cae313702cd Paul Mackerras 2018-10-08 337 } >> 8c99d34578628b Tianjia Zhang 2020-04-27 338 r =3D kvmhv_run_s= ingle_vcpu(vcpu, hdec_exp, lpcr); >> 360cae313702cd Paul Mackerras 2018-10-08 339 } while (is_kvmppc= _resume_guest(r)); >> 360cae313702cd Paul Mackerras 2018-10-08 340 >> 360cae313702cd Paul Mackerras 2018-10-08 341 /* save L2 state f= or return */ >> 360cae313702cd Paul Mackerras 2018-10-08 342 l2_regs =3D vcpu->= arch.regs; >> 360cae313702cd Paul Mackerras 2018-10-08 343 l2_regs.msr =3D vc= pu->arch.shregs.msr; >> 360cae313702cd Paul Mackerras 2018-10-08 344 delta_purr =3D vcp= u->arch.purr - l2_hv.purr; >> 360cae313702cd Paul Mackerras 2018-10-08 345 delta_spurr =3D vc= pu->arch.spurr - l2_hv.spurr; >> 360cae313702cd Paul Mackerras 2018-10-08 346 delta_ic =3D vcpu-= >arch.ic - l2_hv.ic; >> 360cae313702cd Paul Mackerras 2018-10-08 347 delta_vtb =3D vc->= vtb - l2_hv.vtb; >> 360cae313702cd Paul Mackerras 2018-10-08 348 save_hv_return_sta= te(vcpu, vcpu->arch.trap, &l2_hv); >> 360cae313702cd Paul Mackerras 2018-10-08 349 >> 360cae313702cd Paul Mackerras 2018-10-08 350 /* restore L1 stat= e */ >> 360cae313702cd Paul Mackerras 2018-10-08 351 vcpu->arch.nested = =3D NULL; >> 360cae313702cd Paul Mackerras 2018-10-08 352 vcpu->arch.regs = =3D saved_l1_regs; >> 360cae313702cd Paul Mackerras 2018-10-08 353 vcpu->arch.shregs.= msr =3D saved_l1_regs.msr & ~MSR_TS_MASK; >> 360cae313702cd Paul Mackerras 2018-10-08 354 /* set L1 MSR TS f= ield according to L2 transaction state */ >> 360cae313702cd Paul Mackerras 2018-10-08 355 if (l2_regs.msr & = MSR_TS_MASK) >> 360cae313702cd Paul Mackerras 2018-10-08 356 vcpu->arch.shregs= .msr |=3D MSR_TS_S; >> 360cae313702cd Paul Mackerras 2018-10-08 357 vc->tb_offset =3D = saved_l1_hv.tb_offset; >> 360cae313702cd Paul Mackerras 2018-10-08 358 restore_hv_regs(vc= pu, &saved_l1_hv); >> 360cae313702cd Paul Mackerras 2018-10-08 359 vcpu->arch.purr += =3D delta_purr; >> 360cae313702cd Paul Mackerras 2018-10-08 360 vcpu->arch.spurr += =3D delta_spurr; >> 360cae313702cd Paul Mackerras 2018-10-08 361 vcpu->arch.ic +=3D= delta_ic; >> 360cae313702cd Paul Mackerras 2018-10-08 362 vc->vtb +=3D delta= _vtb; >> 360cae313702cd Paul Mackerras 2018-10-08 363 >> 360cae313702cd Paul Mackerras 2018-10-08 364 kvmhv_put_nested(l= 2); >> 360cae313702cd Paul Mackerras 2018-10-08 365 >> 360cae313702cd Paul Mackerras 2018-10-08 366 /* copy l2_hv_stat= e and regs back to guest */ >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 367 if (kvmppc_need_by= teswap(vcpu)) { >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 368 byteswap_hv_regs(= &l2_hv); >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 369 byteswap_pt_regs(= &l2_regs); >> 10b5022db7861a Suraj Jitindar Singh 2018-10-08 370 } >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 371 vcpu->srcu_idx =3D= srcu_read_lock(&vcpu->kvm->srcu); >> afe75049303f75 Ravi Bangoria 2020-12-16 372 err =3D kvmhv_writ= e_guest_state_and_regs(vcpu, &l2_hv, &l2_regs, >> afe75049303f75 Ravi Bangoria 2020-12-16 373 hv_ptr,= regs_ptr); >> 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 374 srcu_read_unlock(&= vcpu->kvm->srcu, vcpu->srcu_idx); >> 360cae313702cd Paul Mackerras 2018-10-08 375 if (err) >> 360cae313702cd Paul Mackerras 2018-10-08 376 return H_AUTHORIT= Y; >> 360cae313702cd Paul Mackerras 2018-10-08 377 >> 360cae313702cd Paul Mackerras 2018-10-08 378 if (r =3D -EINTR) >> 360cae313702cd Paul Mackerras 2018-10-08 379 return H_INTERRUP= T; >> 360cae313702cd Paul Mackerras 2018-10-08 380 >> 873db2cd9a6d7f Suraj Jitindar Singh 2018-12-14 381 if (vcpu->mmio_nee= ded) { >> 873db2cd9a6d7f Suraj Jitindar Singh 2018-12-14 382 kvmhv_nested_mmio= _needed(vcpu, regs_ptr); >> 873db2cd9a6d7f Suraj Jitindar Singh 2018-12-14 383 return H_TOO_HARD; >> 873db2cd9a6d7f Suraj Jitindar Singh 2018-12-14 384 } >> 873db2cd9a6d7f Suraj Jitindar Singh 2018-12-14 385 >> 360cae313702cd Paul Mackerras 2018-10-08 386 return vcpu->arch.= trap; >> 360cae313702cd Paul Mackerras 2018-10-08 387 } >> 360cae313702cd Paul Mackerras 2018-10-08 388 >> >> :::::: The code at line 264 was first introduced by commit >> :::::: 360cae313702cdd0b90f82c261a8302fecef030a KVM: PPC: Book3S HV: Nes= ted guest entry via hypercall >> >> :::::: TO: Paul Mackerras >> :::::: CC: Michael Ellerman >> >> --- >> 0-DAY CI Kernel Test Service, Intel Corporation >> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org >>