From patchwork Thu Jan 21 22:49:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Poimboeuf X-Patchwork-Id: 8085521 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 78A1B9F6FA for ; Thu, 21 Jan 2016 22:54:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A83C520457 for ; Thu, 21 Jan 2016 22:54:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7725220454 for ; Thu, 21 Jan 2016 22:54:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752466AbcAUWyV (ORCPT ); Thu, 21 Jan 2016 17:54:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59969 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752261AbcAUWvb (ORCPT ); Thu, 21 Jan 2016 17:51:31 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id D02C5C0ED3E0; Thu, 21 Jan 2016 22:51:30 +0000 (UTC) Received: from treble.redhat.com (ovpn-113-111.phx2.redhat.com [10.3.113.111]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0LMoHqP029284; Thu, 21 Jan 2016 17:51:28 -0500 From: Josh Poimboeuf To: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Michal Marek , Peter Zijlstra , Andy Lutomirski , Borislav Petkov , Linus Torvalds , Andi Kleen , Pedro Alves , Namhyung Kim , Bernd Petrovitsch , Chris J Arges , Andrew Morton , Jiri Slaby , Arnaldo Carvalho de Melo , Gleb Natapov , Paolo Bonzini , kvm@vger.kernel.org Subject: [PATCH 26/33] x86/kvm: Add stack frame dependency to test_cc() inline asm Date: Thu, 21 Jan 2016 16:49:30 -0600 Message-Id: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With some configs, gcc doesn't inline test_cc(). When that happens, it doesn't create a stack frame before inserting the call instruction. This breaks frame pointer convention if CONFIG_FRAME_POINTER is enabled and can result in a bad stack trace. Force a stack frame to be created if CONFIG_FRAME_POINTER is enabled by listing the stack pointer as an output operand for the inline asm statement. Signed-off-by: Josh Poimboeuf Cc: Gleb Natapov Cc: Paolo Bonzini Cc: kvm@vger.kernel.org --- arch/x86/kvm/emulate.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index aa4d726..7dba65a 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -972,11 +972,13 @@ static int em_bsr_c(struct x86_emulate_ctxt *ctxt) static u8 test_cc(unsigned int condition, unsigned long flags) { u8 rc; + register void *__sp asm(_ASM_SP); void (*fop)(void) = (void *)em_setcc + 4 * (condition & 0xf); flags = (flags & EFLAGS_MASK) | X86_EFLAGS_IF; asm("push %[flags]; popf; call *%[fastop]" - : "=a"(rc) : [fastop]"r"(fop), [flags]"r"(flags)); + : "=a"(rc), "+r"(__sp) + : [fastop]"r"(fop), [flags]"r"(flags)); return rc; }