From patchwork Mon Jul 23 12:41:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10540155 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 258A691E for ; Mon, 23 Jul 2018 12:46:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14BFF2847D for ; Mon, 23 Jul 2018 12:46:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0856D28689; Mon, 23 Jul 2018 12:46:10 +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=-2.9 required=2.0 tests=BAYES_00,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 5085A2847D for ; Mon, 23 Jul 2018 12:46:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 18D766B0008; Mon, 23 Jul 2018 08:46:08 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 164A36B000C; Mon, 23 Jul 2018 08:46:08 -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 02AA66B000D; Mon, 23 Jul 2018 08:46:07 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id B60956B0008 for ; Mon, 23 Jul 2018 08:46:07 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id m25-v6so262542pgv.22 for ; Mon, 23 Jul 2018 05:46:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:user-agent :mime-version; bh=omooxAeIwSrjoQfYpwJwTPbz0qqDZHLZN5s/EQPwNmU=; b=cDsLNyXMphxYNPAO2xPYyoYZnH1bG/JIFNJsGH/xgIx1Bv7k58O0H/JHUVCPa2Kjvt zKMUDSkTkSig6OxJEBPPMmJUl+R7zf47RL7faYHvkue8Fh6Sw4D8uVVvTlux2s9IS4CM HPt6FnWa18SbZr5xZBIH7Wb8IbKkF3CjlpSeQz7ozB03Q+kqJKJJUX07fRGlQ2UkCdZ3 rnLtD144NDUy44srTvzMifvL/U37mtBOYxwvGsFBFXCArTJyivtHLgnwGVYTB4QpF7r+ XsmRgtOj3uHjA6Ja1fqm8OgyD4LmKSl6ve9uoyjyEj+8yURK2pUclxAG2xAGRtaTOZkX yCBg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of gregkh@linuxfoundation.org designates 140.211.169.12 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org X-Gm-Message-State: AOUpUlFLTqk3nS0zi3KmFV6zRf/mXAw9I9EBkHgxoN8hMhZ+f1I51wio ZOCSouIYoHNBBky5Xc+VCudejbIfIthm7joXgyqMhjV/EGe+M5gaj1Ek3nB7/UqGuh1rGpnPBls 5VWY7KVsNEbPhuOUrn6TrJ/CgnydfuNyD43/rwFsSEsGR6LJ1cpBNBw3NQhVcv7DdBA== X-Received: by 2002:a65:53cb:: with SMTP id z11-v6mr12025169pgr.218.1532349967421; Mon, 23 Jul 2018 05:46:07 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeO08xaJEUnOTANArWQE35rbh/jlxcb1sc2duhsQIdXLYcGgOI3hhIh9ddzb0YpVFd5oI9e X-Received: by 2002:a65:53cb:: with SMTP id z11-v6mr12025116pgr.218.1532349966549; Mon, 23 Jul 2018 05:46:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532349966; cv=none; d=google.com; s=arc-20160816; b=sVTAWL9TlAHFIZzzdkCFwDRBpZkKpFMVPAwWkd3qzLpuY1/4BCHB8neLXrMrVb5pyo eipLKO1cBSC21fHv237RH0Pg+7/bLtV6xVCwM8fZa6dLXrBWoKkoAEYqO9vo+mGHjaq1 zXWbqsdc5+dNK6xGKQoO7GhNZyqM9LT57xp+bIfJT5/cb3CPgktbqi/QhsgZ5O8p1FRG wV+59HwfEx4q5mJlwysB0NMrGww6gURgQErt9GuTvuTLHlKvks+Xo2bb9sDXa4rFW752 NFQ3kyn0LR1+69crUIcHEIc5oMQlL2FXGXeLIDKrarHVyzDZnY5EU6e8lK9LUCyFzL+W tFIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=omooxAeIwSrjoQfYpwJwTPbz0qqDZHLZN5s/EQPwNmU=; b=R4mUAxjqZnf3NOELkXHCH5XkbJO9jAAD8p/7EbC8z+U+Qcrff/XNMIAWkx9S0zHT6I hfH4ZtLWLYxKLo9+Z4FZMYRigTR6sh0WXMfrJ2vdfR/bGc+MHzV59dElDsu0ldGU/tpj xNuSW2sLc6LjWBysLtSlN/eEqVxyxkGXVK7GwYtpxWNjGJapSwcLEwvexeG0kNCdD7sE /4ciBKUa/7eXitHguoED3fFkbDOqDk6e5SrUFhEJlQkKJyTv63RRVszu7Q+YkaBtOS20 Y7QKpKhg2QYTauLgNw3Gq8D9hnTn+l97WiUPyX+GjVVUwpGXW3bzi7cS5lsf3JVQraL0 Ww9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gregkh@linuxfoundation.org designates 140.211.169.12 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org. [140.211.169.12]) by mx.google.com with ESMTPS id y62-v6si8970145pfd.254.2018.07.23.05.46.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Jul 2018 05:46:06 -0700 (PDT) Received-SPF: pass (google.com: domain of gregkh@linuxfoundation.org designates 140.211.169.12 as permitted sender) client-ip=140.211.169.12; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gregkh@linuxfoundation.org designates 140.211.169.12 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Received: from localhost (LFbn-1-12238-233.w90-92.abo.wanadoo.fr [90.92.53.233]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3D661C9F; Mon, 23 Jul 2018 12:44:06 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dave Hansen , Thomas Gleixner , Andrew Morton , Andy Lutomirski , Borislav Petkov , Brian Gerst , Dave Hansen , Denys Vlasenko , "H. Peter Anvin" , Linus Torvalds , Peter Zijlstra , Rik van Riel , linux-mm@kvack.org, Ingo Molnar , "Srivatsa S. Bhat" , "Matt Helsley (VMware)" , Alexey Makhalov , Bo Gan Subject: [PATCH 4.4 037/107] x86/mm: Factor out LDT init from context init Date: Mon, 23 Jul 2018 14:41:31 +0200 Message-Id: <20180723122414.735940678@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180723122413.003644357@linuxfoundation.org> References: <20180723122413.003644357@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dave Hansen commit 39a0526fb3f7d93433d146304278477eb463f8af upstream The arch-specific mm_context_t is a great place to put protection-key allocation state. But, we need to initialize the allocation state because pkey 0 is always "allocated". All of the runtime initialization of mm_context_t is done in *_ldt() manipulation functions. This renames the existing LDT functions like this: init_new_context() -> init_new_context_ldt() destroy_context() -> destroy_context_ldt() and makes init_new_context() and destroy_context() available for generic use. Signed-off-by: Dave Hansen Reviewed-by: Thomas Gleixner Cc: Andrew Morton Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Dave Hansen Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Rik van Riel Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/20160212210234.DB34FCC5@viggo.jf.intel.com Signed-off-by: Ingo Molnar Signed-off-by: Srivatsa S. Bhat Reviewed-by: Matt Helsley (VMware) Reviewed-by: Alexey Makhalov Reviewed-by: Bo Gan Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/mmu_context.h | 21 ++++++++++++++++----- arch/x86/kernel/ldt.c | 4 ++-- 2 files changed, 18 insertions(+), 7 deletions(-) --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h @@ -52,15 +52,15 @@ struct ldt_struct { /* * Used for LDT copy/destruction. */ -int init_new_context(struct task_struct *tsk, struct mm_struct *mm); -void destroy_context(struct mm_struct *mm); +int init_new_context_ldt(struct task_struct *tsk, struct mm_struct *mm); +void destroy_context_ldt(struct mm_struct *mm); #else /* CONFIG_MODIFY_LDT_SYSCALL */ -static inline int init_new_context(struct task_struct *tsk, - struct mm_struct *mm) +static inline int init_new_context_ldt(struct task_struct *tsk, + struct mm_struct *mm) { return 0; } -static inline void destroy_context(struct mm_struct *mm) {} +static inline void destroy_context_ldt(struct mm_struct *mm) {} #endif static inline void load_mm_ldt(struct mm_struct *mm) @@ -102,6 +102,17 @@ static inline void enter_lazy_tlb(struct this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY); } +static inline int init_new_context(struct task_struct *tsk, + struct mm_struct *mm) +{ + init_new_context_ldt(tsk, mm); + return 0; +} +static inline void destroy_context(struct mm_struct *mm) +{ + destroy_context_ldt(mm); +} + extern void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk); --- a/arch/x86/kernel/ldt.c +++ b/arch/x86/kernel/ldt.c @@ -119,7 +119,7 @@ static void free_ldt_struct(struct ldt_s * we do not have to muck with descriptors here, that is * done in switch_mm() as needed. */ -int init_new_context(struct task_struct *tsk, struct mm_struct *mm) +int init_new_context_ldt(struct task_struct *tsk, struct mm_struct *mm) { struct ldt_struct *new_ldt; struct mm_struct *old_mm; @@ -160,7 +160,7 @@ out_unlock: * * 64bit: Don't touch the LDT register - we're already in the next thread. */ -void destroy_context(struct mm_struct *mm) +void destroy_context_ldt(struct mm_struct *mm) { free_ldt_struct(mm->context.ldt); mm->context.ldt = NULL; From patchwork Mon Jul 23 12:41:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10540157 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0C62F91E for ; Mon, 23 Jul 2018 12:46:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE3A22847D for ; Mon, 23 Jul 2018 12:46:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E051F28689; Mon, 23 Jul 2018 12:46:14 +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=-2.9 required=2.0 tests=BAYES_00,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 4603F2847D for ; Mon, 23 Jul 2018 12:46:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 55CB26B000D; Mon, 23 Jul 2018 08:46:13 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 50C536B000E; Mon, 23 Jul 2018 08:46:13 -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 422386B0010; Mon, 23 Jul 2018 08:46:13 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 02CDD6B000D for ; Mon, 23 Jul 2018 08:46:13 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id g5-v6so270646pgv.12 for ; Mon, 23 Jul 2018 05:46:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:user-agent :mime-version; bh=rT0Nj8NY55Tm5/lCaoTIvZqIb+llNwCSI/k0fhbWTtU=; b=kC2UL8MDWAE4aoGUXSfl0JcgMNHZ55VK59tAfX5goZtnrcwYK1aTujk9Y9o5cqRANr 1z8+HGH3x1yKbWpyJOmOc/d1cflGHNy0j0bDt36tZTgyW6JezmJopkx2e6EROCOa3Q37 EiJU0EPujaxpFwAJkINSnpuOpZUuuyJuSOqRlTJbp/c+7R05/77w6qQm9l4tQhGJqzIO 2o6F5wlBDgn0Fnx3EAVCNw9o1GWIxwpn7YF2J033riCXX6g1dT0BjIYlCvuBI9WSmNpR eREScy9Y4Bz4U3XBCvr3orlfCQCn0EvKMf1oUilh1DLpzvkOalaCMQJe0y3G3IcK7t84 2zTw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of gregkh@linuxfoundation.org designates 140.211.169.12 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org X-Gm-Message-State: AOUpUlH02j1WzAHsIGfHsdYdduZBMbcAosOLH3qGroLgR1F1Aw25bQCN aVnVJod0QpYw2IummfXx9mSQxjkB4xv/+dEkleKYcTHbUYMIkQEHiygxYD7Kbtmr/Fkm7Kozjzt 1+wFR016lI0QCKMAwR0DjVERKqojDcHjg5f5SnRgrTgSqtC8lnqJzN8zbYWu7xgJIVg== X-Received: by 2002:a63:5e45:: with SMTP id s66-v6mr12112958pgb.151.1532349972675; Mon, 23 Jul 2018 05:46:12 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc4EZUoO7fMWsdjn48T3onOY220VPVj8BkiSxATKmtWXq0D65SDniq4ESJ1Gayu4vPeEs5d X-Received: by 2002:a63:5e45:: with SMTP id s66-v6mr12112902pgb.151.1532349971898; Mon, 23 Jul 2018 05:46:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532349971; cv=none; d=google.com; s=arc-20160816; b=sGVyjTf8wbTteFDsvFf5q/ApyvCjaDyL1uaMky62pfMrJNLz4jUMhJnayyURXeXauD Wu9yiI3kvxqMsj68Af7NRf0MwpbMf8/ndz/wFm+p8RuLHE3mLS+mbvBzDtHS2UoHZSEf 4BtXuLqBOTVC4Z+/yV0zsrh+7uUXhKJHxr2bpJfyIvRHIxC+OIfsYr9xBY5oAG1QqnC9 iCx7hhegy+Uv2Lm5xNeu/OCFE4BconCaHZVXAQePGg9siAGNB8RhViCoeh3gcfYcpizC XOLzlHbu82PctGBvQKOnSjQ8Gu3MniHzdz2uQ5vULtvXSDQ7jvlrzn3dg8MUUPVsq8Hs pQGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=rT0Nj8NY55Tm5/lCaoTIvZqIb+llNwCSI/k0fhbWTtU=; b=E5q//GavdlCbMUS8d8CXWGj+etC/pLXFCnRkFsp1ZIGBOpXAUUrSt7gxTmOz/8so6q js3k38VWKxnMafHVwmvJOVOu7X48NRn7W2JjfEt+bU248fLM2hwFNLHcTfqoVFjSZTor KQwzH4MqQ9y4VsRPP+gPFOt4f4NP7Zjsx9QL6nvCtFjjvUlutcN7yJI+X8kVsTWaoyWr QkLsv9uzuti3EG+2UCjDk/smAJIMaOV5K3VUzDo/WHru9i3e9THS1nNhRrxpB1hl9Hfy OAEOtFn6bBLozqcFdf1tNXSLX9berUNLqMWDxTXyN/eL8kBdDJ70v6oZSnCgUZKGSOmX LvJw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gregkh@linuxfoundation.org designates 140.211.169.12 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org. [140.211.169.12]) by mx.google.com with ESMTPS id z20-v6si9746580pfj.337.2018.07.23.05.46.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Jul 2018 05:46:11 -0700 (PDT) Received-SPF: pass (google.com: domain of gregkh@linuxfoundation.org designates 140.211.169.12 as permitted sender) client-ip=140.211.169.12; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gregkh@linuxfoundation.org designates 140.211.169.12 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Received: from localhost (LFbn-1-12238-233.w90-92.abo.wanadoo.fr [90.92.53.233]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 055E7CA1; Mon, 23 Jul 2018 12:44:09 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Lutomirski , Nadav Amit , Thomas Gleixner , Andrew Morton , Arjan van de Ven , Borislav Petkov , Dave Hansen , Linus Torvalds , Mel Gorman , Peter Zijlstra , Rik van Riel , linux-mm@kvack.org, Ingo Molnar , Tim Chen , "Srivatsa S. Bhat" , "Matt Helsley (VMware)" , Alexey Makhalov , Bo Gan Subject: [PATCH 4.4 038/107] x86/mm: Give each mm TLB flush generation a unique ID Date: Mon, 23 Jul 2018 14:41:32 +0200 Message-Id: <20180723122414.789067704@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180723122413.003644357@linuxfoundation.org> References: <20180723122413.003644357@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andy Lutomirski commit f39681ed0f48498b80455095376f11535feea332 upstream. This adds two new variables to mmu_context_t: ctx_id and tlb_gen. ctx_id uniquely identifies the mm_struct and will never be reused. For a given mm_struct (and hence ctx_id), tlb_gen is a monotonic count of the number of times that a TLB flush has been requested. The pair (ctx_id, tlb_gen) can be used as an identifier for TLB flush actions and will be used in subsequent patches to reliably determine whether all needed TLB flushes have occurred on a given CPU. This patch is split out for ease of review. By itself, it has no real effect other than creating and updating the new variables. Signed-off-by: Andy Lutomirski Reviewed-by: Nadav Amit Reviewed-by: Thomas Gleixner Cc: Andrew Morton Cc: Arjan van de Ven Cc: Borislav Petkov Cc: Dave Hansen Cc: Linus Torvalds Cc: Mel Gorman Cc: Peter Zijlstra Cc: Rik van Riel Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/413a91c24dab3ed0caa5f4e4d017d87b0857f920.1498751203.git.luto@kernel.org Signed-off-by: Ingo Molnar Signed-off-by: Tim Chen Signed-off-by: Greg Kroah-Hartman Signed-off-by: Srivatsa S. Bhat Reviewed-by: Matt Helsley (VMware) Reviewed-by: Alexey Makhalov Reviewed-by: Bo Gan Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/mmu.h | 15 +++++++++++++-- arch/x86/include/asm/mmu_context.h | 4 ++++ arch/x86/mm/tlb.c | 2 ++ 3 files changed, 19 insertions(+), 2 deletions(-) --- a/arch/x86/include/asm/mmu.h +++ b/arch/x86/include/asm/mmu.h @@ -3,12 +3,18 @@ #include #include +#include /* - * The x86 doesn't have a mmu context, but - * we put the segment information here. + * x86 has arch-specific MMU state beyond what lives in mm_struct. */ typedef struct { + /* + * ctx_id uniquely identifies this mm_struct. A ctx_id will never + * be reused, and zero is not a valid ctx_id. + */ + u64 ctx_id; + #ifdef CONFIG_MODIFY_LDT_SYSCALL struct ldt_struct *ldt; #endif @@ -24,6 +30,11 @@ typedef struct { atomic_t perf_rdpmc_allowed; /* nonzero if rdpmc is allowed */ } mm_context_t; +#define INIT_MM_CONTEXT(mm) \ + .context = { \ + .ctx_id = 1, \ + } + void leave_mm(int cpu); #endif /* _ASM_X86_MMU_H */ --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h @@ -11,6 +11,9 @@ #include #include #include + +extern atomic64_t last_mm_ctx_id; + #ifndef CONFIG_PARAVIRT static inline void paravirt_activate_mm(struct mm_struct *prev, struct mm_struct *next) @@ -105,6 +108,7 @@ static inline void enter_lazy_tlb(struct static inline int init_new_context(struct task_struct *tsk, struct mm_struct *mm) { + mm->context.ctx_id = atomic64_inc_return(&last_mm_ctx_id); init_new_context_ldt(tsk, mm); return 0; } --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -29,6 +29,8 @@ * Implement flush IPI by CALL_FUNCTION_VECTOR, Alex Shi */ +atomic64_t last_mm_ctx_id = ATOMIC64_INIT(1); + struct flush_tlb_info { struct mm_struct *flush_mm; unsigned long flush_start;