Received: by 10.223.176.5 with SMTP id f5csp721396wra; Fri, 9 Feb 2018 06:13:08 -0800 (PST) X-Google-Smtp-Source: AH8x2251vcsc4xTsRWsczn83uq6wRbiAuG+pqaVMrCDyxZlWYE1x9298SqxXb/NSbCo9TsfXkk1F X-Received: by 10.99.156.10 with SMTP id f10mr140966pge.12.1518185587944; Fri, 09 Feb 2018 06:13:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518185587; cv=none; d=google.com; s=arc-20160816; b=RxcOfsu1yqcQ/wId/EwcL0uJRUedELW0Fblb6XeDrg/Q5x32oddJFTK4v4/PdgHCTP vb9AJ71ZmDXMDxjN0dcHqrizm1RodXRrHRQCFl3Bma2qoS4tq7WexabuVcA1tuSn+lCn VrZtH3hXagK8p0h2nYrfWg7KUb1bLdnzaBto1VPtrjmaOB5sIj1D3wD4aN7yCa2878Yy 2Obc1xbVLTza+lZAS3YP0RNnzf+/aK8pN1u5MUhi4sTIYCpiOVuQaRR36kNDHofiG/8I +14y6Z+6D762VqikantBzDHwwUQ4BiB14ptZLrDyH7pVdepV9ZPDWleBy3R9HeM8snLi hyww== 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=ufZPNq/U3e+4gvswkjmcBgQgBBghFOHoXMWKonaW2bw=; b=NBA+YLb8YQKhlznfW+Lx/mTGc8TLxRvSjIrFRY8kQTByxn1GE0KsMDjLjf3vsnK6oe EAsnWIuG228IlaOLdqvIZGAi8SRuY1j6QI7PQaWzJ28QSxitBpJVhnlHXaU6ucV7gSJh sXhXzWf6aQ+HzCXpj+AC97rvckkAukJWkkCYUZ8BnL9KdFCkI2pGg8YiezZ/FATbOQmu 9SH39ugAXIO4wkRcYCHw1HvAqRe7zC5h17h3lMh3bc4IvrH0KgFB2OzlxX9PMrc82wxX kUlENJrM1yfSY0h8iY65BxvYIrdeVEriNmniDM5kc/kPs8s0XCEBQMm0PscaeBLavJHO sDrQ== 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 q74si1643822pfk.164.2018.02.09.06.12.52; Fri, 09 Feb 2018 06:13:07 -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 S1752868AbeBIOMQ (ORCPT + 99 others); Fri, 9 Feb 2018 09:12:16 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:49468 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751140AbeBINlx (ORCPT ); Fri, 9 Feb 2018 08:41:53 -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 5547AF30; Fri, 9 Feb 2018 13:41:52 +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.9 36/92] KVM: x86: Make indirect calls in emulator speculation safe Date: Fri, 9 Feb 2018 14:39:05 +0100 Message-Id: <20180209133933.771072983@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180209133931.211869118@linuxfoundation.org> References: <20180209133931.211869118@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.9-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 Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/emulate.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 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" @@ -1012,8 +1013,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; } @@ -5306,15 +5307,14 @@ static void fetch_possible_mmx_operand(s static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *)) { - register void *__sp asm(_ASM_SP); 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), "+r"(__sp) + [thunk_target]"+S"(fop), ASM_CALL_CONSTRAINT : "c"(ctxt->src2.val)); ctxt->eflags = (ctxt->eflags & ~EFLAGS_MASK) | (flags & EFLAGS_MASK);