Received: by 10.223.185.116 with SMTP id b49csp3210770wrg; Mon, 5 Mar 2018 16:37:48 -0800 (PST) X-Google-Smtp-Source: AG47ELvOp9XZtOjpUzGnZ7KlbTLByGcQfHOTngnN/+NggZm3/0+hFwf48uWxlBzIxMlEFj1EW82i X-Received: by 2002:a17:902:365:: with SMTP id 92-v6mr14968138pld.127.1520296668404; Mon, 05 Mar 2018 16:37:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520296668; cv=none; d=google.com; s=arc-20160816; b=Becxh1W0kQ7Wa0MQMUi60Zo8zdvObuOz8Rq9QxCCCRrTWMzsxn0I1nEKZS8VGDA7yc HTQph1PrIHddGwkMW0G7nzLJ6/20u1CpSpx7RPMvq1b0dmoHAlgaeoPZWOT9SpqjoO7V inqLxTpptslMXhulvjkkvq8BNhY8Czig9PTvwd9w6CKd9SwjtwNSElZ7pfVjAo24MNud pswg7PZBZqHXh7IPPmdyMkLDLWflLvYe//sgEMmVo7X2QhhWjQSrPFjvSZxO7q8hGT2W YAZ9pO/DLrChK7Exn04rrezZ1m9Ava//Jn822Eac129v3dCEZVPm4gfAFIZMvLKOJwzS sH5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:arc-authentication-results; bh=0E/A+WS3Ey7sYZ822dXZd0RTzhKuTS/sM22xTBn5WRY=; b=NYJRk0hUc/Q8kRSPS8DI2q5EHJ4rg0MS+mSFgMnWNToXsw/tMPc8ePMb0PWLTxl1tJ jjh6XmxlzaBpxwbPIgzht8icXKa+2Ja9YgQVa3OPJfbKJ8w2xuHKUpq3BWyka9y4/r7U VwdeYwPoLaYfZUTsP0uiauCPIKB4VdVl22O3Q6UOY3El6SoB5pMIaX3ViCi78vTlpQiQ ure4sLBqwzD8nhDshMESl+oTeRZy8z+Yp9asfqnL6Tcbaf09Q809FRY9/p85lZUzfgcJ ydwpI5TaeL3uPwMHOsPVr+DVl+JZaD85Owni0rNJ83wM/DnFRZanxq3MRykd2HF/GvWO 0pTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=Ro8GWzvH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b7-v6si10236070plk.592.2018.03.05.16.37.34; Mon, 05 Mar 2018 16:37:48 -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; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=Ro8GWzvH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933616AbeCFAfu (ORCPT + 99 others); Mon, 5 Mar 2018 19:35:50 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:56378 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933219AbeCFA0c (ORCPT ); Mon, 5 Mar 2018 19:26:32 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w260LTlq034883; Tue, 6 Mar 2018 00:26:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=0E/A+WS3Ey7sYZ822dXZd0RTzhKuTS/sM22xTBn5WRY=; b=Ro8GWzvHhQZTIA7xgIOPUklLw8Kiqm4226QT6KnwNJH/pCNWwgr5b9ZFiu40fHRj15GW /n4gxjigYEbW5WZdz9IH43KgFv+rjay+kbMCqqnonXxY8gxqd6u9p2+EpOwdXM6zz1n3 JEqXhD+c9XQ9ut/30zwxNuvykAWV+cfSj3GAPdS651xI4c/L38rVAhshSO+cnWah+SPU fj44HTA3ZMLly9Sr3ptmREeOKOJTCiKzqtHDehgrdqpaF0LzLJ3+XfAgz6gaqAvurAgf b7AWwl402L0LxgGru3wmo4pzjE+ZLdus8S9Ap9Kf7fPG+psTtdYrLfkADdWAtxVkvnQy ZA== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2ghe3kgg40-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Mar 2018 00:26:28 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w260QROL025676 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 6 Mar 2018 00:26:27 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w260QRn4000349; Tue, 6 Mar 2018 00:26:27 GMT Received: from localhost.localdomain (/98.216.35.41) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 05 Mar 2018 16:26:26 -0800 From: Pavel Tatashin To: steven.sistare@oracle.com, daniel.m.jordan@oracle.com, linux-kernel@vger.kernel.org, Alexander.Levin@microsoft.com, dan.j.williams@intel.com, sathyanarayanan.kuppuswamy@intel.com, pankaj.laxminarayan.bharadiya@intel.com, akuster@mvista.com, cminyard@mvista.com, pasha.tatashin@oracle.com, gregkh@linuxfoundation.org, stable@vger.kernel.org Subject: [PATCH 4.1 32/65] kaiser: fix regs to do_nmi() ifndef CONFIG_KAISER Date: Mon, 5 Mar 2018 19:25:05 -0500 Message-Id: <20180306002538.1761-33-pasha.tatashin@oracle.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180306002538.1761-1-pasha.tatashin@oracle.com> References: <20180306002538.1761-1-pasha.tatashin@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8823 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803060003 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hugh Dickins pjt has observed that nmi's second (nmi_from_kernel) call to do_nmi() adjusted the %rdi regs arg, rightly when CONFIG_KAISER, but wrongly when not CONFIG_KAISER. Although the minimal change is to add an #ifdef CONFIG_KAISER around the addq line, that looks cluttered, and I prefer how the first call to do_nmi() handled it: prepare args in %rdi and %rsi before getting into the CONFIG_KAISER block, since it does not touch them at all. And while we're here, place the "#ifdef CONFIG_KAISER" that follows each, to enclose the "Unconditionally restore CR3" comment: matching how the "Unconditionally use kernel CR3" comment above is enclosed. Signed-off-by: Hugh Dickins Acked-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 487f0b73d82611a2dc48d7d78409e2e9d994006a) Signed-off-by: Pavel Tatashin Conflicts: arch/x86/entry/entry_64.S (not in this tree) arch/x86/kernel/entry_64.S (patched instead of that) --- arch/x86/kernel/entry_64.S | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S index 1bda5ebd1013..8e4056d4b1d6 100644 --- a/arch/x86/kernel/entry_64.S +++ b/arch/x86/kernel/entry_64.S @@ -1547,12 +1547,12 @@ ENTRY(nmi) movq %rax, %cr3 #endif call do_nmi +#ifdef CONFIG_KAISER /* * Unconditionally restore CR3. I know we return to * kernel code that needs user CR3, but do we ever return * to "user mode" where we need the kernel CR3? */ -#ifdef CONFIG_KAISER popq %rax mov %rax, %cr3 #endif @@ -1772,6 +1772,8 @@ end_repeat_nmi: SWAPGS xorl %ebx, %ebx 1: + movq %rsp, %rdi + movq $-1, %rsi #ifdef CONFIG_KAISER /* Unconditionally use kernel CR3 for do_nmi() */ /* %rax is saved above, so OK to clobber here */ @@ -1785,16 +1787,13 @@ end_repeat_nmi: DEFAULT_FRAME 0 /* XXX: Do we need this? */ /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */ - movq %rsp,%rdi - addq $8, %rdi /* point %rdi at ptregs, fixed up for CR3 */ - movq $-1,%rsi call do_nmi +#ifdef CONFIG_KAISER /* * Unconditionally restore CR3. We might be returning to * kernel code that needs user CR3, like just just before * a sysret. */ -#ifdef CONFIG_KAISER popq %rax mov %rax, %cr3 #endif -- 2.16.2