Received: by 10.223.185.116 with SMTP id b49csp2463090wrg; Mon, 5 Mar 2018 03:24:47 -0800 (PST) X-Google-Smtp-Source: AG47ELuwlchfMIaqP9eu/2J1IAe9Dw8zYRkNhKYmuQL3EHKyQQGuTDAoA0iJvxFTB4aw1XZMIdhK X-Received: by 10.167.130.193 with SMTP id f1mr14819390pfn.241.1520249087102; Mon, 05 Mar 2018 03:24:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520249087; cv=none; d=google.com; s=arc-20160816; b=t/SwmXrKgvU/3JrAzCXbEzueQin9UPppvXaydYHa0i3fhy0qz96/o0Y2ueiC7PupCN V1X72ke7Wi2MrgtrbQwarknF1s+pJ7726Ib+P0J1uEK2lkII7ptFXKg/pj2GKrRRi8zT viHVgyJKEiSTIio4Z0VL6k/xaSse1wFf0SdQy3SFJYJqWnkiAaLM6nsy0G/u5QBBsxld 0Ow/FILWPYZv2TN9xDIXkftvFfAH3/WTa0Ysvrpy2EI9X2B11M4Tr5u8I7BZup6j0e3t tcAS/B2ydJyCLISjYti9UBfNpX0jKyyQKRWtNlhkp8jEaoM6LQBvn03IysUft6/hz85+ PIwA== 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=RTCSI4LBCeZ83zvPmZKkwnhJMNZmduT3Jg6qpsJ2ftA=; b=OKoqfD+Zbbvpj9GPYkfvu2kUDN+kFvMZT4BnbdbSeSduLf0eZGnqg0pfgSpnejNeCU j4ytpXKQDU8gD/epcfk/iSHkfBarOnMDsLzb2UinoxWbIF7Jown9eWIxvujoJ+2d6hZj i0AYSLFYhSInSdtbanSNzEpsiNMDvYgOXBnW0mHtoUESZnqca5p4jNfZYhWBEdxWhmtD 0FxyWXOfgLXU64GmPamXbZxhBrWZFtTkSYbE4hxxNSdXGZ3FVUtEB0u2vv8kZfRjodha 7D7oN0unpkfXFknHxnpAymyshX11ATXLr9Doz7ihiQ0INmsdhtzVcIfd5c8vHpQlMfWO UsGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@8bytes.org header.s=mail-1 header.b=i/vNGdLL; 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 23si4328515pfy.85.2018.03.05.03.24.32; Mon, 05 Mar 2018 03:24:47 -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=i/vNGdLL; 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 S934213AbeCEKb4 (ORCPT + 99 others); Mon, 5 Mar 2018 05:31:56 -0500 Received: from 8bytes.org ([81.169.241.247]:54622 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933749AbeCEK0P (ORCPT ); Mon, 5 Mar 2018 05:26:15 -0500 Received: by theia.8bytes.org (Postfix, from userid 1000) id 3780891B; Mon, 5 Mar 2018 11:26:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1520245567; bh=G3AQd/KTMH/wA2WPvEn8aT3Ua9SToItjp7UPjKVr3ac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i/vNGdLLLfR23HMpbIF16TQu5UiT45Qq5FcyI0ECKvpmdNu3Ywx4TKUzq4YbC58KY nHoXQNKrlMRdfj5HzEnzZaiI2PI3m8JjEPseER6mEn0tl+3Qa/N7+z17kmvkFCz/m0 03NriwpzIAR85Ia82hGQiFeKaPT9E19C0Q5d+IOY29fjtfXjxg/znjW4cuz3gkL8Ea o59tBVBWwlif8/fvr6ky3u1sBXnW47ZniUhvLaX1VVe9PVPLptQ5sNTK0gWkfOxdYd P7UpLvBHLB2x/9X9MJ9J3eieJirAx9p7dlMJCg25q+8etNiICb6y39BFrh3HPx290I 6xQNjs9MTU3tw== 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/34] x86/entry/32: Introduce SAVE_ALL_NMI and RESTORE_ALL_NMI Date: Mon, 5 Mar 2018 11:25:39 +0100 Message-Id: <1520245563-8444-11-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520245563-8444-1-git-send-email-joro@8bytes.org> References: <1520245563-8444-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 1b5656d..bb0bd896 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) @@ -1148,7 +1163,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 @@ -1176,7 +1191,7 @@ ENTRY(nmi) .Lnmi_return: CHECK_AND_APPLY_ESPFIX - RESTORE_REGS 4 + RESTORE_ALL_NMI pop=4 jmp .Lirq_return #ifdef CONFIG_X86_ESPFIX32 @@ -1192,12 +1207,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