Received: by 10.223.176.5 with SMTP id f5csp2859779wra; Mon, 5 Feb 2018 11:05:39 -0800 (PST) X-Google-Smtp-Source: AH8x224RLx7guMINQ+8dsZm9LrONQ+BNegpSGeTNo+ePrRKz89wCYjDXi/Zx7WvO8Ft7YXTrgzxf X-Received: by 10.98.204.75 with SMTP id a72mr6010133pfg.33.1517857539188; Mon, 05 Feb 2018 11:05:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517857539; cv=none; d=google.com; s=arc-20160816; b=CWiz8CG15C98wDo9i9k64YNXDHIkd+UybzGMHLoVbcvs+lCryepEdSjYf8OTLq8NlK OJ7J6H+qgHgkUfLzRmQ+dd/7zz1rMQT7kVIcXOKOm+ZGGS3EqHYNRx0bcMx40JtKR+Gu QWo30GFbOUGuLdTEeEgZUBBcmpDJoyhPynIYT5K61ZPx5WfvgunJ62UTN925r3v3azYI bju7SVBa9NRMEBl7PUDTtieYFuO6tt+1ZuficYyDu6MjOsyTE6QdZRF2wMgdCo4sKwKe O95M0eaIAtYAzvhBSPCJOoL36nHg1pS8jCuRb34nViLR96DEp0et27F25Fr6Ooroj1RX B4fA== 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=6Ute/cXyzOGvFlCfltv0bLuNKs+Vd4lAVeK1lLdob0s=; b=MO19V5OxMUAXSuh87iugvejb1GEQzFeRmDk2JlgSOlhIgU3O/nCBjPIlw7CAWNoHJ1 eyB70/tUBRuBMTeRlEENuQoHHT2yUHgrbD9pLWTxh8MwBFuj7MsUEH0UQNj9fbOtSVkD qu9sbxsTu/g0bkhe3zsSvsegcHBSXH4Z+Pwfp5lUsCADyFfezF78021WBZmvFZE8Z4aK X4eCtXTdDqvcIONCYJEMzw0RoUvOrTOtbkjDXwvEUJO1pzymP78nK+06zyXEPnJRmlbn 80kszf6gJY8XozYyu9EoDbKlEttPUkiqYmON7rN6T9wDjugYPjRXasHJPjw7JhscOOL6 ya8A== 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 b24si1393610pfd.321.2018.02.05.11.05.24; Mon, 05 Feb 2018 11:05:39 -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 S1753668AbeBETEv (ORCPT + 99 others); Mon, 5 Feb 2018 14:04:51 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:51268 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753481AbeBESYA (ORCPT ); Mon, 5 Feb 2018 13:24:00 -0500 Received: from localhost (unknown [104.132.1.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 13822100D; Mon, 5 Feb 2018 18:23:57 +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 Subject: [PATCH 4.14 05/64] KVM: x86: Make indirect calls in emulator speculation safe Date: Mon, 5 Feb 2018 10:22:24 -0800 Message-Id: <20180205182138.793954774@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180205182138.571333346@linuxfoundation.org> References: <20180205182138.571333346@linuxfoundation.org> User-Agent: quilt/0.65 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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Peter Zijlstra peterz@infradead.org 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 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 @@ -25,6 +25,7 @@ #include #include #include +#include #include "x86.h" #include "tss.h" @@ -1021,8 +1022,8 @@ static __always_inline u8 test_cc(unsign 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; } @@ -5350,9 +5351,9 @@ static int fastop(struct x86_emulate_ctx 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), ASM_CALL_CONSTRAINT + [thunk_target]"+S"(fop), ASM_CALL_CONSTRAINT : "c"(ctxt->src2.val)); ctxt->eflags = (ctxt->eflags & ~EFLAGS_MASK) | (flags & EFLAGS_MASK);