From nobody Mon Feb 9 04:29:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 041D6C7EE24 for ; Mon, 5 Jun 2023 16:12:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234736AbjFEQMh (ORCPT ); Mon, 5 Jun 2023 12:12:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231881AbjFEQMc (ORCPT ); Mon, 5 Jun 2023 12:12:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A467FB7 for ; Mon, 5 Jun 2023 09:12:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 38D0F6209E for ; Mon, 5 Jun 2023 16:12:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 573E6C4339B; Mon, 5 Jun 2023 16:12:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685981550; bh=Y/CZjNZo+1qpj5wP4ui+d4BljXqVHm12WzlCqm4DwWg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RpTmJiA3wvYc3nJFc3onPNTivqFIDK+4LergCSsq9dPrr2QukzMLRXUwmKxWyMx/H Kkn0zIevs/BE+n6arqBaKP/vrpzIbPzm6NJ9Fn3o4g111hZ+gJD47MzGI0V7lmqiBV L1VewThgnel9XuN25rqbCWprkFBl6SmPbrkVmqUB7df7eRty4T8vlbWjr3aBkVb2hF TLgyeBrq90lX1Gk892f1CWYrdgG10NVby5EkQ3K2g8dT+IkvTSO5DU2EuvWzXXjq+3 duqvTR/JO0GIIYbA3ko+Ms1+R+i18UT4kn3tTFKjnJolDLIhK0Bt/0qTPuMwKwcrNI qeMZLS20qxwPg== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Miroslav Benes , linux-graphics-maintainer@vmware.com, Zack Rusin Subject: [PATCH v2 1/2] objtool: Allow stack operations in UNWIND_HINT_UNDEFINED regions Date: Mon, 5 Jun 2023 09:12:21 -0700 Message-Id: <820c5b433f17c84e8761fb7465a8d319d706b1cf.1685981486.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" If the code specified UNWIND_HINT_UNDEFINED, skip the "undefined stack state" warning due to a stack operation. Just ignore the stack op and continue to propagate the undefined state. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 12 ++++++++++++ tools/objtool/include/objtool/cfi.h | 1 + 2 files changed, 13 insertions(+) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 4b869de7e827..b11c25a715ac 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -33,6 +33,7 @@ static unsigned long nr_cfi, nr_cfi_reused, nr_cfi_cache; static struct cfi_init_state initial_func_cfi; static struct cfi_state init_cfi; static struct cfi_state func_cfi; +static struct cfi_state force_undefined_cfi; =20 struct instruction *find_insn(struct objtool_file *file, struct section *sec, unsigned long offset) @@ -2240,6 +2241,11 @@ static int read_unwind_hints(struct objtool_file *fi= le) =20 insn->hint =3D true; =20 + if (hint->type =3D=3D UNWIND_HINT_TYPE_UNDEFINED) { + insn->cfi =3D &force_undefined_cfi; + continue; + } + if (hint->type =3D=3D UNWIND_HINT_TYPE_SAVE) { insn->hint =3D false; insn->save =3D true; @@ -2793,6 +2799,10 @@ static int update_cfi_state(struct instruction *insn, struct cfi_reg *cfa =3D &cfi->cfa; struct cfi_reg *regs =3D cfi->regs; =20 + /* ignore UNWIND_HINT_UNDEFINED regions */ + if (cfi->force_undefined) + return 0; + /* stack operations don't make sense with an undefined CFA */ if (cfa->base =3D=3D CFI_UNDEFINED) { if (insn_func(insn)) { @@ -4607,6 +4617,8 @@ int check(struct objtool_file *file) init_cfi_state(&init_cfi); init_cfi_state(&func_cfi); set_func_state(&func_cfi); + init_cfi_state(&force_undefined_cfi); + force_undefined_cfi.force_undefined =3D true; =20 if (!cfi_hash_alloc(1UL << (file->elf->symbol_bits - 3))) goto out; diff --git a/tools/objtool/include/objtool/cfi.h b/tools/objtool/include/ob= jtool/cfi.h index b1258e79a1b7..c8a6bec4f6b9 100644 --- a/tools/objtool/include/objtool/cfi.h +++ b/tools/objtool/include/objtool/cfi.h @@ -36,6 +36,7 @@ struct cfi_state { bool drap; bool signal; bool end; + bool force_undefined; }; =20 #endif /* _OBJTOOL_CFI_H */ --=20 2.40.1 From nobody Mon Feb 9 04:29:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77C44C7EE2C for ; Mon, 5 Jun 2023 16:12:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234678AbjFEQMk (ORCPT ); Mon, 5 Jun 2023 12:12:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233545AbjFEQMc (ORCPT ); Mon, 5 Jun 2023 12:12:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3510BBD for ; Mon, 5 Jun 2023 09:12:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9C1EC627F4 for ; Mon, 5 Jun 2023 16:12:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB561C433A4; Mon, 5 Jun 2023 16:12:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685981551; bh=GbiswfqlPKxb8y7Cgh7d9fzBotuGBKD2mu+cvUJpcr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PhicJi3EulNDmKVT5zOxoXSJn8Gf9Ok6AcSu2Q4X/qtJ8svD2SxRIhxqV4QoEQ7Jz mslv+YWbWjpGC5c2mluIh5YPn3aPAhYOwO/Au2IRgxV6VttYqBGKllB1kTCG39R1Yn uRcrWyMFVUW8b3VPBeQC3DG3e8PKNxfAb5q9pOZEnSfQz2RRop8Pmh/bOAkvEe7r3x b/ntM4UQ1nPaMtPZU+8QYXS1ofomme3x9xrfOp91VnInn4jW7cI4mWvNiXE+/1MXae ZwofIIPgM/E1kdH1c7+LL9v1uw7odHN165s4CPspOItUOu5Lq8lUG1cc3ec8c2phdR JLhSV/jb4B7xw== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Miroslav Benes , linux-graphics-maintainer@vmware.com, Zack Rusin , kernel test robot Subject: [PATCH v2 2/2] drm/vmwgfx: Add unwind hints around RBP clobber Date: Mon, 5 Jun 2023 09:12:22 -0700 Message-Id: <4c795f2d87bc0391cf6543bcb224fa540b55ce4b.1685981486.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" VMware high-bandwidth hypercalls take the RBP register as input. This breaks basic frame pointer convention, as RBP should never be clobbered. So frame pointer unwinding is broken for the instructions surrounding the hypercalls. Fortunately this doesn't break live patching with CONFIG_FRAME_POINTER, as it only unwinds from blocking tasks, and stack traces from preempted tasks are already marked unreliable anyway. However, for live patching with ORC, this could actually be a theoretical problem if vmw_port_hb_{in,out}() were still compiled with a frame pointer due to having an aligned stack. In practice that hasn't seemed to be an issue since the objtool warnings have only been seen with CONFIG_FRAME_POINTER. Add unwind hint annotations to tell the ORC unwinder to mark stack traces as unreliable. Fixes the following warnings: vmlinux.o: warning: objtool: vmw_port_hb_in+0x1df: return with modified s= tack frame vmlinux.o: warning: objtool: vmw_port_hb_out+0x1dd: return with modified = stack frame Fixes: 89da76fde68d ("drm/vmwgfx: Add VMWare host messaging capability") Reported-by: kernel test robot Link: https://lore.kernel.org/oe-kbuild-all/202305160135.97q0Elax-lkp@intel= .com/ Signed-off-by: Josh Poimboeuf --- arch/x86/include/asm/unwind_hints.h | 9 +++++++++ drivers/gpu/drm/vmwgfx/vmwgfx_msg_x86.h | 16 ++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/unwind_hints.h b/arch/x86/include/asm/unw= ind_hints.h index 01cb9692b160..85cc57cb6539 100644 --- a/arch/x86/include/asm/unwind_hints.h +++ b/arch/x86/include/asm/unwind_hints.h @@ -76,9 +76,18 @@ =20 #else =20 +#define UNWIND_HINT_UNDEFINED \ + UNWIND_HINT(UNWIND_HINT_TYPE_UNDEFINED, 0, 0, 0) + #define UNWIND_HINT_FUNC \ UNWIND_HINT(UNWIND_HINT_TYPE_FUNC, ORC_REG_SP, 8, 0) =20 +#define UNWIND_HINT_SAVE \ + UNWIND_HINT(UNWIND_HINT_TYPE_SAVE, 0, 0, 0) + +#define UNWIND_HINT_RESTORE \ + UNWIND_HINT(UNWIND_HINT_TYPE_RESTORE, 0, 0, 0) + #endif /* __ASSEMBLY__ */ =20 #endif /* _ASM_X86_UNWIND_HINTS_H */ diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg_x86.h b/drivers/gpu/drm/vmwg= fx/vmwgfx_msg_x86.h index 0b74ca2dfb7b..23899d743a90 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg_x86.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg_x86.h @@ -105,10 +105,14 @@ flags, magic, bp, \ eax, ebx, ecx, edx, si, di) \ ({ \ - asm volatile ("push %%rbp;" \ + asm volatile ( \ + UNWIND_HINT_SAVE \ + "push %%rbp;" \ + UNWIND_HINT_UNDEFINED \ "mov %12, %%rbp;" \ VMWARE_HYPERCALL_HB_OUT \ - "pop %%rbp;" : \ + "pop %%rbp;" \ + UNWIND_HINT_RESTORE : \ "=3Da"(eax), \ "=3Db"(ebx), \ "=3Dc"(ecx), \ @@ -130,10 +134,14 @@ flags, magic, bp, \ eax, ebx, ecx, edx, si, di) \ ({ \ - asm volatile ("push %%rbp;" \ + asm volatile ( \ + UNWIND_HINT_SAVE \ + "push %%rbp;" \ + UNWIND_HINT_UNDEFINED \ "mov %12, %%rbp;" \ VMWARE_HYPERCALL_HB_IN \ - "pop %%rbp" : \ + "pop %%rbp;" \ + UNWIND_HINT_RESTORE : \ "=3Da"(eax), \ "=3Db"(ebx), \ "=3Dc"(ecx), \ --=20 2.40.1