From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x227TVYvfp/el5IoPO9k25xyWDTXYP1+NtZy/ttOjFEV9P13XMQCYzB9IePjnO+Pgz0grF90G ARC-Seal: i=1; a=rsa-sha256; t=1516876676; cv=none; d=google.com; s=arc-20160816; b=zUW1pFzHBBNIrD4v+F6ivSS2s87ylZW/ApxJGPcx+MQ9W/xecks1rhEqHosXBozb9J DMwCDtiFa4W7fDxOXJkbGlXnagmPQKxu4xRXbYlCpwIXNJi5HAUUCn1vGYU26FNw3Tod wnzJs7rc8fvTcN1hGrhrE16cG5NWFu2OSECXVxAncCaEA6D9Je3Fa3zhmoriImjGpY+Q pOB6UUs/wYOvdvXXIhcWVtdZqmi6cnbTA8HmB2PlNZed5DGxuM5P+Ud9fWuTrzMEtKFF eJUH4lNQetvyugJA344aFEcQOSfVC1oX5WjHV9KlGFVG2MZ2IAkRzGftr568svSlfxwg Xzpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=precedence:content-disposition:content-transfer-encoding :mime-version:robot-unsubscribe:robot-id:git-commit-id:subject:to :references:in-reply-to:reply-to:cc:message-id:from:sender:date :arc-authentication-results; bh=UC9YWnsLZ662ijq0jLr5+wY/RqoDQjfEGSMPj3CunEI=; b=cpq8zZGW9UL01vLw+XJwkdC5yh06sK23c+6uNlrbQr8TzU9Nz0a9HxkKv8MIPhUZzu +db/5lDPhAJipiXKUnuIQyhwngK9r/x98yGcJxcXbOQHft/Kpi9IdEepaGojy5CRlzZM hWcIm+b9hdTG946vReqaD0EkoGuoewkN9bvHeA9NlufzWE6m4FgphrfdhPLkOKs5KtEZ eliPHiAfE1+X4H5xO6maFjDUguAc9n0c3IuW5TTqWjtwwOT++r/qk7MnFtltZmQuMMuF 5IHyUjRxUiViW89PiROf+gVoAbvmiv7z1K3LCnvxID5SE0IELoH6e6xcshNzNuaxcwNU WbQw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of tipbot@zytor.com designates 65.50.211.136 as permitted sender) smtp.mailfrom=tipbot@zytor.com Authentication-Results: mx.google.com; spf=pass (google.com: domain of tipbot@zytor.com designates 65.50.211.136 as permitted sender) smtp.mailfrom=tipbot@zytor.com Date: Thu, 25 Jan 2018 02:34:12 -0800 Sender: tip tree robot From: tip-bot for Peter Zijlstra Message-ID: Cc: tglx@linutronix.de, jpoimboe@redhat.com, dan.j.williams@intel.com, ashok.raj@intel.com, aarcange@redhat.com, jun.nakajima@intel.com, luto@kernel.org, torvalds@linux-foundation.org, arjan.van.de.ven@intel.com, hpa@zytor.com, tim.c.chen@linux.intel.com, dwmw@amazon.co.uk, gregkh@linuxfoundation.org, asit.k.mallick@intel.com, jbaron@akamai.com, pbonzini@redhat.com, ak@linux.intel.com, mingo@kernel.org, dwmw2@infradead.org, dave.hansen@intel.com, linux-kernel@vger.kernel.org, peterz@infradead.org Reply-To: dwmw2@infradead.org, peterz@infradead.org, linux-kernel@vger.kernel.org, dave.hansen@intel.com, jbaron@akamai.com, asit.k.mallick@intel.com, pbonzini@redhat.com, ak@linux.intel.com, mingo@kernel.org, torvalds@linux-foundation.org, arjan.van.de.ven@intel.com, hpa@zytor.com, dwmw@amazon.co.uk, tim.c.chen@linux.intel.com, gregkh@linuxfoundation.org, tglx@linutronix.de, jpoimboe@redhat.com, dan.j.williams@intel.com, ashok.raj@intel.com, aarcange@redhat.com, luto@kernel.org, jun.nakajima@intel.com In-Reply-To: <20180125095843.595615683@infradead.org> References: <20180125095843.595615683@infradead.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/pti] KVM: x86: Make indirect calls in emulator speculation safe Git-Commit-ID: 1a29b5b7f347a1a9230c1e0af5b37e3e571588ab X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1590560477102441919?= X-GMAIL-MSGID: =?utf-8?q?1590560477102441919?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: Commit-ID: 1a29b5b7f347a1a9230c1e0af5b37e3e571588ab Gitweb: https://git.kernel.org/tip/1a29b5b7f347a1a9230c1e0af5b37e3e571588ab Author: Peter Zijlstra AuthorDate: Thu, 25 Jan 2018 10:58:13 +0100 Committer: Thomas Gleixner CommitDate: Thu, 25 Jan 2018 11:30:07 +0100 KVM: x86: Make indirect calls in emulator speculation safe 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 --- arch/x86/kvm/emulate.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index d90cdc7..453d8c9 100644 --- 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(unsigned int condition, unsigned long flags) 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; } @@ -5305,9 +5306,9 @@ static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *)) 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);