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;