Received: by 10.223.185.116 with SMTP id b49csp1121053wrg; Fri, 23 Feb 2018 12:17:29 -0800 (PST) X-Google-Smtp-Source: AH8x225C8utqUyDk+YRamMd0g8pR55bQ78d3Y09d+yu956WY6nrX6HKlcEnGmoXy9xUEPiws5sHD X-Received: by 2002:a17:902:3183:: with SMTP id x3-v6mr2734298plb.383.1519417049192; Fri, 23 Feb 2018 12:17:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519417049; cv=none; d=google.com; s=arc-20160816; b=l6VJBTA2F6UoUuy17Vwn/zvesbbVsTU78uxvGqb57cRZ41glZeHS+MDzTXKztCPlGS clnNKFRG8ltGoNsjzCH1SefCOVUMxgvsPQ/yCKo1Ae94MkDX4/i4iMyuL4jZK6McYNSY Nx45CSCrPPSM/E2gZxqAvJg8L5YqCSHRM2nL+A6QINijGgWNslHElSvI2b8rOXLeMzCx HLhi+ex3lFFWctTM4mdqZxY+Kz6CqJM27sLDyXroZGSOe+EOfWmp3Hg9h0ipN4jIsU9g 15t7Z/71Wxz4AbGzkOn0L8qqspIocrTNFvJwor/8zeeE8+50QIFgKuMMXwUViEnStdTm NiKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=DjFF6T9ZSIRRywSafnfS7uKy/3jJXE1S23PO5Z7oBsg=; b=J5rkYm61Q2nfjhnTZXvpO6MLrwBXSCGb6aJQvL83ovO6n0lW4iN+O0F+aQg4W5QcmN PXdNPuTwroP13ZDbBHJnUO2x+daH6tB274QTVOpfrqn5BwP2GO1w8yD2kJ732cOFeK4t 9ah0GZdm0Ahh9A+cI2ipCxhzw5+0HtgdSgtS6mxh/mu650YiTvxOgDQYBmuFFyL/Y6L2 BfO14F5X+j7ZkZXgBcT4mLLKFsyI5eO/LqaQbd8l1XM/ZAYhSD/j7qGjHkxbtKlvDV+b MjTFeCfrlTd6cbydr3Q+Q0LJkzbVbaYp5ptO+P/b6P96PU72bIsERCFYQzrC1BrSgKIR SsGA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b84si2293022pfj.183.2018.02.23.12.17.14; Fri, 23 Feb 2018 12:17:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755227AbeBWUQh (ORCPT + 99 others); Fri, 23 Feb 2018 15:16:37 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:40058 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932465AbeBWSk2 (ORCPT ); Fri, 23 Feb 2018 13:40:28 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 6C03411E9; Fri, 23 Feb 2018 18:40:27 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Peter Zijlstra (Intel)" , Thomas Gleixner , David Woodhouse , Andrea Arcangeli , Andi Kleen , Ashok Raj , Jun Nakajima , David Woodhouse , Linus Torvalds , rga@amazon.de, Dave Hansen , Asit Mallick , Andy Lutomirski , Josh Poimboeuf , Jason Baron , Paolo Bonzini , Dan Williams , Arjan Van De Ven , Tim Chen , Jack Wang Subject: [PATCH 4.4 166/193] KVM: x86: Make indirect calls in emulator speculation safe Date: Fri, 23 Feb 2018 19:26:39 +0100 Message-Id: <20180223170351.993016228@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170325.997716448@linuxfoundation.org> References: <20180223170325.997716448@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Peter Zijlstra (cherry picked from commit 1a29b5b7f347a1a9230c1e0af5b37e3e571588ab) Replace the indirect calls with CALL_NOSPEC. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Thomas Gleixner Reviewed-by: David Woodhouse Cc: Andrea Arcangeli Cc: Andi Kleen Cc: Ashok Raj Cc: Greg KH Cc: Jun Nakajima Cc: David Woodhouse Cc: Linus Torvalds Cc: rga@amazon.de Cc: Dave Hansen Cc: Asit Mallick Cc: Andy Lutomirski Cc: Josh Poimboeuf Cc: Jason Baron Cc: Paolo Bonzini Cc: Dan Williams Cc: Arjan Van De Ven Cc: Tim Chen Link: https://lkml.kernel.org/r/20180125095843.595615683@infradead.org [dwmw2: Use ASM_CALL_CONSTRAINT like upstream, now we have it] Signed-off-by: David Woodhouse [backport to 4.4] Signed-off-by: Jack Wang Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/emulate.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "x86.h" #include "tss.h" @@ -1000,8 +1001,8 @@ static u8 test_cc(unsigned int condition 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)); + asm("push %[flags]; popf; " CALL_NOSPEC + : "=a"(rc) : [thunk_target]"r"(fop), [flags]"r"(flags)); return rc; } @@ -5297,9 +5298,9 @@ static int fastop(struct x86_emulate_ctx ulong flags = (ctxt->eflags & EFLAGS_MASK) | X86_EFLAGS_IF; if (!(ctxt->d & ByteOp)) fop += __ffs(ctxt->dst.bytes) * FASTOP_SIZE; - asm("push %[flags]; popf; call *%[fastop]; pushf; pop %[flags]\n" + asm("push %[flags]; popf; " CALL_NOSPEC "; pushf; pop %[flags]\n" : "+a"(ctxt->dst.val), "+d"(ctxt->src.val), [flags]"+D"(flags), - [fastop]"+S"(fop) + [thunk_target]"+S"(fop) : "c"(ctxt->src2.val)); ctxt->eflags = (ctxt->eflags & ~EFLAGS_MASK) | (flags & EFLAGS_MASK); if (!fop) /* exception is returned in fop variable */