Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5763828imm; Mon, 23 Jul 2018 05:47:36 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdKnf6ioGxJVgkfXMVRBURK6vEDam1wCpA2bNlCxGUoYn5iopIgIdpwo0/2aeO1mCHdcdb/ X-Received: by 2002:a65:4384:: with SMTP id m4-v6mr714529pgp.265.1532350056403; Mon, 23 Jul 2018 05:47:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532350056; cv=none; d=google.com; s=arc-20160816; b=JhGiyMVtN/RcQ/FHMr7qGcFFeVWIqHqGWqhxdHxyNesjwiyDcCWrsZ/QfMiCs2vBWW OetFKsCLziIvWEiycnD3JFuv+HUeEQkWYkaXcDNLLDkV6Xl4lRRZd2FUAGki/4SY/aYC 7lbWv8hw6AwnBKzWnXj72WMnwLXkVz/Kz/8ZEu+DKTlSD8X3Ka89Bt74QHOR5zTgu2D1 tZWQYBEBLX9VDmmXk9nmm+BZY7bIYAAf9wCrOuSGjz1SkH4O+fZY6szTt0pM81J5PZtL 1kYWTWOoSEHRx+qc6hnjKb9BnjE4JPaFy3CRabaxzw+VBG/XzsUOL9SlLIz+my9LmsqF mcYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=omooxAeIwSrjoQfYpwJwTPbz0qqDZHLZN5s/EQPwNmU=; b=tbUsOOSVJUBwcrjfb6361s+SJSzPE4UG7r9o0SuxQROoRL94jUq4oZfKzVep/s5+jg PxlHF4U8IA0uYYGdXXrOGhMJM2r0ro+cPXxEvwZmbCealiVSF/Cd2H7Ej7X3PW+KFPBz uS5Bl7RZCo6x7UpUKkeVoG9NIxIfNVnbHF9lVUQ2hI0iGoZkw5ETLTHQuRI84W/jpOoE j7MmUjIXVfTuYO3FJad/OROVBbWHGJgXI0apS/t5VCqjcBNzF3AKr/BLkR3GAZuQnBQt pB5aNjn7ehHZ/PuDGkZ6pmzQ07bXC/A6M9IsFbv4HJ1Wo79BdgRRZ9tMFBz2o7xNf+vA t+qA== 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 d4-v6si8189694pla.81.2018.07.23.05.47.21; Mon, 23 Jul 2018 05:47:36 -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 S2388818AbeGWNrL (ORCPT + 99 others); Mon, 23 Jul 2018 09:47:11 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50718 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388007AbeGWNrL (ORCPT ); Mon, 23 Jul 2018 09:47:11 -0400 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 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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;