From patchwork Fri Jul 20 16:22:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 10537947 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A9C616029B for ; Fri, 20 Jul 2018 16:22:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 995582957B for ; Fri, 20 Jul 2018 16:22:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C2642971B; Fri, 20 Jul 2018 16:22:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B7652957B for ; Fri, 20 Jul 2018 16:22:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AAC006B000A; Fri, 20 Jul 2018 12:22:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A5D226B000E; Fri, 20 Jul 2018 12:22:42 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D5446B000D; Fri, 20 Jul 2018 12:22:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by kanga.kvack.org (Postfix) with ESMTP id 183C36B000C for ; Fri, 20 Jul 2018 12:22:42 -0400 (EDT) Received: by mail-ed1-f69.google.com with SMTP id w10-v6so4902009eds.7 for ; Fri, 20 Jul 2018 09:22:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=ggIGRB+Y/gtXbLlucNcTDkCpcGgc8/+mBFxNZLf1Dn8=; b=RRIkjEnHZ7lJPglyINjxe5aCjnRUtuMerLQ+vpr/6wEqMeK+bHoUx6eSzUKSQjftz/ DQiiR/PAmiH0ajyO9HZRfkG/haXOMqi7BTsmA/EtsPD6zXHsEJ8/IT2GSCjgD2+BBOQL WoliPGr0k/LpROHqf1f0dWty4MFF5TcflpIdNMHf/SuWeiit+zmtO+BqSGpHa8MLp/1Q hXN/JR7j3z7bcmtMU5CbnwQjm1LvYR5PGM7aZNiIJDIml7fE8deR+3SWESLcRpuoCEv0 ltPzPNzIasgzhnXhf/c4yp6cu5dzNlUQrfQNIrb/UsNtA4h07FtkZfcNYS0vzKNRcaz+ iKeg== X-Gm-Message-State: AOUpUlEc+TSAv48qjbSYPlnSmP71D+LExUsHlqzh/MPoriUGOIHXb3CA nSFffYedWRg6QyDYQD7V9oIiekHUGOzPVZmhE+3WD2apQQp3GzUeTkj1ZHC2/vN1lUfkL+nDJkE w7CplX2FO3qge7n3u24axqZnJaVDpEq+EOiuyWVh7yWNDbqgGD6Dj1AG1Xh3JE2m4dQ== X-Received: by 2002:a50:e718:: with SMTP id a24-v6mr3344325edn.278.1532103761659; Fri, 20 Jul 2018 09:22:41 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdmFjjuUZBCfcRM840D7R2lEEFQxqLXJ4QNvyeI9dc0BGGzFr8j2DGiQSf6A8Kj5jeMW2vz X-Received: by 2002:a50:e718:: with SMTP id a24-v6mr3344290edn.278.1532103760955; Fri, 20 Jul 2018 09:22:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532103760; cv=none; d=google.com; s=arc-20160816; b=FtCigLYQFfmNuE6lqDSNT2Ji1+KuH2JWgmpEdC5qvtIByknXsOxZ071oJaf9FAEA7C 0satxcPl3765X+Jzi4hjjTOVWa8vObm4eEUM7DvIFox4znTYbEpXNA0KJSTNVmTb6kaI FH/KUp7ipevL80WOu/dZxetsmcmyYsDcdtWTxceyhE+RwLCvpjJNW2TrqZy4WNBODODe RVwz1PTJGGC+4qblbGSnZqkT/YwK/3YSWZ22wTriyxMYMv/SFM3Ze7IL2CUVfh+WngJ8 Lt+qTa33pbUMhMbkJKFx/kWqQeY5GhbnJQp8jZ1a77E1EXfUf+yngUmPyty1bJZ6uaXB hsow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=ggIGRB+Y/gtXbLlucNcTDkCpcGgc8/+mBFxNZLf1Dn8=; b=v+DsyoEDltq5pP04aKM61bw826CjGKcSD79kP0c6pFviLOOMxLp7x4nkmzMF9jm/Qp vbFKZ530kASB1+sQCcj+DuL+Gc/j7bAsdT1pLnavuKNTX61txnQlbxBAcnj/O0nwItY3 hgkbySJRMK8iDC30TYClfTS/ztlY0X8N1sSAMlY73uVleHVPA2AcHLJZ+PEIDLpLmMvB 2VGLOQBd9+JcW8PdkKWt16mzLiJ1kUGvV4SukvIAhBYfMagv5b1HWJOiCPLIgxm+q2y2 qpdwISkWpcdDMtV/MpJvtLLFwGq4AmhiKrHcNuv3Oohf5pE3zLQoKWfuMcSZzPkIx2zG yVeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=jBrZd1xf; spf=pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: from theia.8bytes.org (8bytes.org. [81.169.241.247]) by mx.google.com with ESMTPS id 5-v6si1931338edo.397.2018.07.20.09.22.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Jul 2018 09:22:40 -0700 (PDT) Received-SPF: pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) client-ip=81.169.241.247; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=jBrZd1xf; spf=pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: by theia.8bytes.org (Postfix, from userid 1000) id 5EC2147B; Fri, 20 Jul 2018 18:22:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1532103759; bh=4KTDetwc2za08ZBDrrEdYFeqtUqIJZdCy2mgZWB4/5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jBrZd1xflyjidAw0e7BS6prO+8qCnAtDYqk2xh5lrukP/n5XrVELBoV3MGwc6TKVk JDG1nN7MSAsrAN3lX7Zg9tgj8AY9OxBPb5Qc5xpJbDtKaUbc0Gh+WXJCz6UvGQmvu/ V97lm5OZkmzTLBy5OZvUeDzayAD+LUGIk1YAusZIuurPukGRSPxEL7bDzcgBX5hDnG SK3ohiJ322ZzQkm2RA8dwJ8d6jSr/1a8KZfmTChTXa6Bxf94iSWHUPkb3ICsLAWm9Q 5XLq0dnCv/dHpTKZMWWxO5+ldjsSBOjmAa2jR+/S4IcodVU8Y2gk2gTELjnLumHEH9 tplzyeIw6H91Q== 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 , "David H . Gutteridge" , jroedel@suse.de, Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , joro@8bytes.org Subject: [PATCH 2/3] x86/entry/32: Check for VM86 mode in slow-path check Date: Fri, 20 Jul 2018 18:22:23 +0200 Message-Id: <1532103744-31902-3-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1532103744-31902-1-git-send-email-joro@8bytes.org> References: <1532103744-31902-1-git-send-email-joro@8bytes.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Joerg Roedel 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 --- 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 010cdb4..2767c62 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