Received: by 10.223.176.5 with SMTP id f5csp447850wra; Fri, 9 Feb 2018 01:35:05 -0800 (PST) X-Google-Smtp-Source: AH8x224v+CmTPgVFrgTQ7th7KKqHUQEMOcgbm5lTTgrjgy6IngJioNQqeb6jud8UlVkLK8vA1ny0 X-Received: by 10.101.64.67 with SMTP id h3mr1862405pgp.168.1518168905889; Fri, 09 Feb 2018 01:35:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518168905; cv=none; d=google.com; s=arc-20160816; b=0J4tVNDYRkrjkB+PY5fNjDm4XI3xjJh1rKRMVtpSpbthKX3yE7x1v+eV11RK4XbZpI DWs6N6V8eJW/JLZsASimwB7L2nYK1wBpVpfmedJvu4AgDnDLMFyxwPFnSD4xXzD/+Fd5 +ZYCheNTHrzzJ9yPqOOYz/vR6nMpjzUpkWjlelI160s1+hr8j9yC0gizxZ8hpSGwkMY7 QiL8cFdo/8k5fxjqjDK+YUT6Yz2gwxCg6EzbmCshVEZ+q0CEa7D0l7JBrT1m+r8HQsec KRoRaTFLk2cRdyS8MWg52uXfJMkl8oHHMOn2dLsVE3l2+1WVGJxHRBxdcA929tcaceoe PkaQ== 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:cc:to:from:dkim-signature:arc-authentication-results; bh=9KTRuSx/r+96S1uyk96OvYxonlJ2rVE9rGTZcS4J7y8=; b=mNiTwnMzL6ixsyoFKon41UhIWWRXlGthr8Z7O/il6xI6pCyLb9w8r9vgbP6dvB0QeI HiBx+V4ezdmk0f2bEBO2eJ0dd7Mv6O7X0kxPmTYkEluAPWpkOCo5lS55uM/iA4jB4U4N ItUdi5M+qm5kQK35w8U0/GOsLoWPV3UOjREj/iL0pum7B8RoEI5be3MQ4pH7Qg9wXWF0 xot6qQKoAg+mmCiG9J8ah81M9yqN4pFgAlmNtv7I6RBR0msH84FiD/ssfJNzq0eWPOni M0aL8CV0YG/Qs3stl17XRPGmFEAriPGTVcc0NdCiYLsrZVCc/4fkYgc+C9MzvguaMX0N mL5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@8bytes.org header.s=mail-1 header.b=k46sgjGD; 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=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g30si1160641pgn.394.2018.02.09.01.34.48; Fri, 09 Feb 2018 01:35:05 -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=fail (test mode) header.i=@8bytes.org header.s=mail-1 header.b=k46sgjGD; 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=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752292AbeBIJ0H (ORCPT + 99 others); Fri, 9 Feb 2018 04:26:07 -0500 Received: from 8bytes.org ([81.169.241.247]:43052 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752184AbeBIJZ7 (ORCPT ); Fri, 9 Feb 2018 04:25:59 -0500 Received: by theia.8bytes.org (Postfix, from userid 1000) id CC7F47B0; Fri, 9 Feb 2018 10:25:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1518168352; bh=W9T/oR8WgM2hZDMCjhNOxZPfFMG45QC+a/QBv6lqF/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k46sgjGDxKHpyAERcsZCAX0zMaFJ7h4AJtj5seesp0ST0uGRjGSPEgKXHZheP0mZO J4Tvle8fUz5QUglNtxXhq6w4PNvnncXx5eTRH5lPWmDOSonL1aKhzE4PNFjMUiJ8n4 ya2ttjqoToIgxd6ayb7cfFkvywBSG0rACBD5IGWimVYFHzjYxkm3yGDX7RAmOX+Duz s0S8pEZErwmls3dXTe8SYWoyihvNfbcSL1Fefws3Rlk5z8F43jhTy1sxP51g53OmCL HoYFQpZ4o6Upr9wW2z+vAPbQEbtIpB//hKnYoPuY8iJRJVDngxiExbZiWNT9B+Uj5E Rypo71rZo1/GA== From: Joerg Roedel To: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Andy Lutomirski , Dave Hansen , Josh Poimboeuf , Juergen Gross , Peter Zijlstra , Borislav Petkov , Jiri Kosina , Boris Ostrovsky , Brian Gerst , David Laight , Denys Vlasenko , Eduardo Valentin , Greg KH , Will Deacon , aliguori@amazon.com, daniel.gruss@iaik.tugraz.at, hughd@google.com, keescook@google.com, Andrea Arcangeli , Waiman Long , Pavel Machek , jroedel@suse.de, joro@8bytes.org Subject: [PATCH 10/31] x86/entry/32: Introduce SAVE_ALL_NMI and RESTORE_ALL_NMI Date: Fri, 9 Feb 2018 10:25:19 +0100 Message-Id: <1518168340-9392-11-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518168340-9392-1-git-send-email-joro@8bytes.org> References: <1518168340-9392-1-git-send-email-joro@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel These macros will be used in the NMI handler code and replace plain SAVE_ALL and RESTORE_REGS there. We will add the NMI-specific CR3-switch to these macros later. Signed-off-by: Joerg Roedel --- arch/x86/entry/entry_32.S | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S index ba3d8c2..be1d814 100644 --- a/arch/x86/entry/entry_32.S +++ b/arch/x86/entry/entry_32.S @@ -167,6 +167,9 @@ .endm +.macro SAVE_ALL_NMI + SAVE_ALL +.endm /* * This is a sneaky trick to help the unwinder find pt_regs on the stack. The * frame pointer is replaced with an encoded pointer to pt_regs. The encoding @@ -224,6 +227,18 @@ RESTORE_SKIP_SEGMENTS \pop .endm +.macro RESTORE_ALL_NMI pop=0 + /* + * Restore segments - might cause exceptions when loading + * user-space segments + */ + RESTORE_SEGMENTS + + /* Restore integer registers and unwind stack to iret frame */ + RESTORE_INT_REGS + RESTORE_SKIP_SEGMENTS \pop +.endm + .macro CHECK_AND_APPLY_ESPFIX #ifdef CONFIG_X86_ESPFIX32 #define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8) @@ -1127,7 +1142,7 @@ ENTRY(nmi) #endif pushl %eax # pt_regs->orig_ax - SAVE_ALL + SAVE_ALL_NMI ENCODE_FRAME_POINTER xorl %edx, %edx # zero error code movl %esp, %eax # pt_regs pointer @@ -1155,7 +1170,7 @@ ENTRY(nmi) .Lnmi_return: CHECK_AND_APPLY_ESPFIX - RESTORE_REGS 4 + RESTORE_ALL_NMI pop=4 jmp .Lirq_return #ifdef CONFIG_X86_ESPFIX32 @@ -1171,12 +1186,12 @@ ENTRY(nmi) pushl 16(%esp) .endr pushl %eax - SAVE_ALL + SAVE_ALL_NMI ENCODE_FRAME_POINTER FIXUP_ESPFIX_STACK # %eax == %esp xorl %edx, %edx # zero error code call do_nmi - RESTORE_REGS + RESTORE_ALL_NMI lss 12+4(%esp), %esp # back to espfix stack jmp .Lirq_return #endif -- 2.7.4