Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2503765imu; Thu, 17 Jan 2019 15:45:13 -0800 (PST) X-Google-Smtp-Source: ALg8bN53wZhPzsK1lZ4X1WrLf1Ao/Ny8DkCl/wN7Ddmn85kxT8dH4mf/hrSti6FG5Ofy0Z5+GgZS X-Received: by 2002:a63:f047:: with SMTP id s7mr15318368pgj.441.1547768713893; Thu, 17 Jan 2019 15:45:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547768713; cv=none; d=google.com; s=arc-20160816; b=HRjyJqBOS7Yv9GuxsIVDC8cATYZYnTjgmlp0N+wtd/M/4paLmkclC0p/sCKtLkY4m2 Yp3PmgCANhvhAJruN2P5f6/nEGviAj+5kwJUtHbryyuBdHUP1tnIdd2q6c9QA7Bk/zuz x2L7qmxNh9z0XZKqi2bmO3GUqGw8ZWUb3FSI61GkpswOBY/5MU28tHx5pKQpl5529YeY Adjde7gNCeiAsQmvtMF9L/36nXbkzZWuJDb95/n+W0MRe+WmaMGrTKp0RDRfvIl1pRNZ gphBtmNIfeKG/nbZtZs+07qr5AC9kAJ7HGmROemKhoShqA8EeimOoV3gUKdYo2ory0ct YU5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender: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:date; bh=VeCE2X6+/4dTrbqB4ZC1XxWp7drMtkiG/xK1nI06OT4=; b=tf+qb8sAcegjgfyzzn/JFgVssw0KNSHdKIlBPmBPj/kt47i9hZdQ3nQmW8Zwo5prjA 2/dlIdMh5iZk8QXe3aPu6XhaGZv/K8qWYHX+o4bdLUGCCOE53Wc/YDFvwOab2qB0fDlC H+lJHF9JOOQFeFPbwaOc/mOM+5HRA6AwYGERi4cBuwN2Wr5WFYXzotTj8gFfrBdRqa6Y FkvSoBBxNJ9NrmWMemiZAY1K1CDTM6JAhGZtvYjwwVoSk1OPMEKRth58dvAfXjK7U7/p uVIwuGhSUlX4GLJPV4tnof+EUeUi6WXFDDy3qhoiE1cAUK7tG3o443BXdb1NvJmC2Fo3 6D4w== 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 x1si2932255plb.366.2019.01.17.15.44.52; Thu, 17 Jan 2019 15:45:13 -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 S1727081AbfAQXnJ (ORCPT + 99 others); Thu, 17 Jan 2019 18:43:09 -0500 Received: from terminus.zytor.com ([198.137.202.136]:45241 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726008AbfAQXnI (ORCPT ); Thu, 17 Jan 2019 18:43:08 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x0HNgu0C946463 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Thu, 17 Jan 2019 15:42:56 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x0HNguGG946460; Thu, 17 Jan 2019 15:42:56 -0800 Date: Thu, 17 Jan 2019 15:42:56 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Jan Beulich Message-ID: Cc: luto@kernel.org, linux-kernel@vger.kernel.org, jbeulich@suse.com, mingo@kernel.org, boris.ostrovsky@oracle.com, hpa@zytor.com, JBeulich@suse.com, tglx@linutronix.de, jgross@suse.com Reply-To: jbeulich@suse.com, linux-kernel@vger.kernel.org, luto@kernel.org, mingo@kernel.org, hpa@zytor.com, boris.ostrovsky@oracle.com, jgross@suse.com, tglx@linutronix.de, JBeulich@suse.com In-Reply-To: <5C3E1128020000780020DFAD@prv1-mh.provo.novell.com> References: <5C3E1128020000780020DFAD@prv1-mh.provo.novell.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/entry/64/compat: Fix stack switching for XEN PV Git-Commit-ID: fc24d75a7f91837d7918e40719575951820b2b8f 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-Spam-Status: No, score=-0.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_48_96 autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: fc24d75a7f91837d7918e40719575951820b2b8f Gitweb: https://git.kernel.org/tip/fc24d75a7f91837d7918e40719575951820b2b8f Author: Jan Beulich AuthorDate: Tue, 15 Jan 2019 09:58:16 -0700 Committer: Thomas Gleixner CommitDate: Fri, 18 Jan 2019 00:39:33 +0100 x86/entry/64/compat: Fix stack switching for XEN PV While in the native case entry into the kernel happens on the trampoline stack, PV Xen kernels get entered with the current thread stack right away. Hence source and destination stacks are identical in that case, and special care is needed. Other than in sync_regs() the copying done on the INT80 path isn't NMI / #MC safe, as either of these events occurring in the middle of the stack copying would clobber data on the (source) stack. There is similar code in interrupt_entry() and nmi(), but there is no fixup required because those code paths are unreachable in XEN PV guests. [ tglx: Sanitized subject, changelog, Fixes tag and stable mail address. Sigh ] Fixes: 7f2590a110b8 ("x86/entry/64: Use a per-CPU trampoline stack for IDT entries") Signed-off-by: Jan Beulich Signed-off-by: Thomas Gleixner Reviewed-by: Juergen Gross Acked-by: Andy Lutomirski Cc: Peter Anvin Cc: xen-devel@lists.xenproject.org> Cc: Boris Ostrovsky Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/5C3E1128020000780020DFAD@prv1-mh.provo.novell.com --- arch/x86/entry/entry_64_compat.S | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S index 8eaf8952c408..39913770a44d 100644 --- a/arch/x86/entry/entry_64_compat.S +++ b/arch/x86/entry/entry_64_compat.S @@ -361,7 +361,8 @@ ENTRY(entry_INT80_compat) /* Need to switch before accessing the thread stack. */ SWITCH_TO_KERNEL_CR3 scratch_reg=%rdi - movq %rsp, %rdi + /* In the Xen PV case we already run on the thread stack. */ + ALTERNATIVE "movq %rsp, %rdi", "jmp .Lint80_keep_stack", X86_FEATURE_XENPV movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp pushq 6*8(%rdi) /* regs->ss */ @@ -370,8 +371,9 @@ ENTRY(entry_INT80_compat) pushq 3*8(%rdi) /* regs->cs */ pushq 2*8(%rdi) /* regs->ip */ pushq 1*8(%rdi) /* regs->orig_ax */ - pushq (%rdi) /* pt_regs->di */ +.Lint80_keep_stack: + pushq %rsi /* pt_regs->si */ xorl %esi, %esi /* nospec si */ pushq %rdx /* pt_regs->dx */