Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3241088imm; Fri, 20 Jul 2018 12:39:56 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc8l1rto5lENrrWVVK6CxGzey9sKvalDgKy9fbQuCXFtlgqTFs6MtfCvq3Oep4JUKb/dThR X-Received: by 2002:a63:f002:: with SMTP id k2-v6mr3229376pgh.8.1532115596077; Fri, 20 Jul 2018 12:39:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532115596; cv=none; d=google.com; s=arc-20160816; b=0IJz0gxQY/PDebTfHWYF1sIrOdIq0dOEPmsg7oNj6XW8jpZ10dfa8eTzPRGCDFilQp zkUionNyJ8fsPKwCKHs5bKGykvn42WqLn7tS49ZsqhRhNUHOk7qnH/wTdg6pbubhpWP7 blTR5Ku04KjzYMHj3X8LI8+lXIUBcYo22q3wRk1gpVv9ty9H0WkvRiR2sZil0pGhHDBh 6OnCHOVhEFtRK9UZluH3Bp+xuAPKg8U2FaKYip31Wb9m+iODu+WuOaE07B5l2JMNxXUk mna+BIl/sAWAhAUXPKKN4Q7lUQUWWm6VRgK0El7b2BL056ltGawMJjnnV1ltg+lRDps7 v/aw== 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:arc-authentication-results; bh=PPSb3OyGWahTi1SBMjQEkitzU9t9FOzqvUUqRHRQUog=; b=R74j9wE5EOTV9PIh9yjCWrVh5HQjJrK6OWehwObJilk+AVxut11ZYXgX2Xx8m8bgAO Z0dht4U73Oyh9zEVTkdtPanVQs+VI3PpuFYFjYzQjFXaon6HX47lYcjde1cJcDKJRzjV EPNDXpQkRyBRUQc2/mdxA5jpeXtqZU3bOAIrLLg+6J/aA4Nn+xV8p0rOLyIr9fgUerxQ gJ/18BwANeb+yX49fcgoT01DSRB3ONefa+Vp3RYXvhePKNmLy0S1vaw8JhWSBRjCIuf6 IpQkIlQHxM6rk3JN07aNY71GszlGOa/xlzxVBN4obGl1X622NHN/9Qj2xEpNpyHw6hCb vDXg== 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 y9-v6si2395828pll.291.2018.07.20.12.39.41; Fri, 20 Jul 2018 12:39:56 -0700 (PDT) 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 S1731692AbeGTU2c (ORCPT + 99 others); Fri, 20 Jul 2018 16:28:32 -0400 Received: from terminus.zytor.com ([198.137.202.136]:43585 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731465AbeGTU2b (ORCPT ); Fri, 20 Jul 2018 16:28:31 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w6KJbbbq2769255 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 20 Jul 2018 12:37:37 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w6KJbbJ32769251; Fri, 20 Jul 2018 12:37:37 -0700 Date: Fri, 20 Jul 2018 12:37:37 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Joerg Roedel Message-ID: Cc: linux-kernel@vger.kernel.org, jpoimboe@redhat.com, bp@alien8.de, dhgutteridge@sympatico.ca, luto@kernel.org, aarcange@redhat.com, torvalds@linux-foundation.org, dvlasenk@redhat.com, pavel@ucw.cz, brgerst@gmail.com, jgross@suse.com, hpa@zytor.com, mingo@kernel.org, jroedel@suse.de, gregkh@linuxfoundation.org, peterz@infradead.org, David.Laight@aculab.com, jolsa@redhat.com, boris.ostrovsky@oracle.com, acme@kernel.org, namhyung@kernel.org, will.deacon@arm.com, jkosina@suse.cz, alexander.shishkin@linux.intel.com, eduval@amazon.com, tglx@linutronix.de, dave.hansen@intel.com, llong@redhat.com Reply-To: gregkh@linuxfoundation.org, jroedel@suse.de, hpa@zytor.com, mingo@kernel.org, brgerst@gmail.com, jgross@suse.com, peterz@infradead.org, David.Laight@aculab.com, alexander.shishkin@linux.intel.com, will.deacon@arm.com, jkosina@suse.cz, acme@kernel.org, namhyung@kernel.org, boris.ostrovsky@oracle.com, jolsa@redhat.com, dave.hansen@intel.com, llong@redhat.com, tglx@linutronix.de, eduval@amazon.com, linux-kernel@vger.kernel.org, jpoimboe@redhat.com, bp@alien8.de, luto@kernel.org, dhgutteridge@sympatico.ca, pavel@ucw.cz, torvalds@linux-foundation.org, dvlasenk@redhat.com, aarcange@redhat.com In-Reply-To: <1532103744-31902-3-git-send-email-joro@8bytes.org> References: <1532103744-31902-3-git-send-email-joro@8bytes.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/pti] x86/entry/32: Check for VM86 mode in slow-path check Git-Commit-ID: 9cd342705877526f387cfcb5df8a964ab5873deb 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=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) 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: 9cd342705877526f387cfcb5df8a964ab5873deb Gitweb: https://git.kernel.org/tip/9cd342705877526f387cfcb5df8a964ab5873deb Author: Joerg Roedel AuthorDate: Fri, 20 Jul 2018 18:22:23 +0200 Committer: Thomas Gleixner CommitDate: Fri, 20 Jul 2018 21:32:08 +0200 x86/entry/32: Check for VM86 mode in slow-path check The SWITCH_TO_KERNEL_STACK macro only checks for CPL == 0 to go down the slow and paranoid entry path. The problem is that this check also returns true when coming from VM86 mode. This is not a problem by itself, as the paranoid path handles VM86 stack-frames just fine, but it is not necessary as the normal code path handles VM86 mode as well (and faster). Extend the check to include VM86 mode. This also makes an optimization of the paranoid path possible. Signed-off-by: Joerg Roedel Signed-off-by: Thomas Gleixner Cc: "H . Peter Anvin" Cc: linux-mm@kvack.org Cc: Linus Torvalds Cc: Andy Lutomirski Cc: Dave Hansen Cc: Josh Poimboeuf Cc: Juergen Gross Cc: Peter Zijlstra Cc: Borislav Petkov Cc: Jiri Kosina Cc: Boris Ostrovsky Cc: Brian Gerst Cc: David Laight Cc: Denys Vlasenko Cc: Eduardo Valentin Cc: Greg KH Cc: Will Deacon Cc: aliguori@amazon.com Cc: daniel.gruss@iaik.tugraz.at Cc: hughd@google.com Cc: keescook@google.com Cc: Andrea Arcangeli Cc: Waiman Long Cc: Pavel Machek Cc: "David H . Gutteridge" Cc: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim Cc: joro@8bytes.org Link: https://lkml.kernel.org/r/1532103744-31902-3-git-send-email-joro@8bytes.org --- arch/x86/entry/entry_32.S | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S index 010cdb41e3c7..2767c625a52c 100644 --- a/arch/x86/entry/entry_32.S +++ b/arch/x86/entry/entry_32.S @@ -414,8 +414,16 @@ andl $(0x0000ffff), PT_CS(%esp) /* Special case - entry from kernel mode via entry stack */ - testl $SEGMENT_RPL_MASK, PT_CS(%esp) - jz .Lentry_from_kernel_\@ +#ifdef CONFIG_VM86 + movl PT_EFLAGS(%esp), %ecx # mix EFLAGS and CS + movb PT_CS(%esp), %cl + andl $(X86_EFLAGS_VM | SEGMENT_RPL_MASK), %ecx +#else + movl PT_CS(%esp), %ecx + andl $SEGMENT_RPL_MASK, %ecx +#endif + cmpl $USER_RPL, %ecx + jb .Lentry_from_kernel_\@ /* Bytes to copy */ movl $PTREGS_SIZE, %ecx