From patchwork Sun Aug 20 10:20:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 110481 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp26178qge; Sun, 20 Aug 2017 03:22:15 -0700 (PDT) X-Received: by 10.84.149.197 with SMTP id a5mr15599069plh.3.1503224535875; Sun, 20 Aug 2017 03:22:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503224535; cv=none; d=google.com; s=arc-20160816; b=DjAZjwfeVibp/07LjqPvaepr2JyD3ZQlUGq2FrmQ5XoQt4y20AbFaw+H17Y1nZ9+3Z 9k8uzrUf6Q3ZcGeyhyENpdt9C9iRGZwOooLcSYz0/zaPtTMI5aviERc3Dakd3l0FFWM7 nxs5Qu/iImhxZ9CrZfB/fC7MNQRgiam4REHGQklg1OAccdC9nnzq+Hw3QcJgqpIMqk3y jBjesPNfDJtuw/+skmjvVZM57V4zjkU2icgAYRYHjyAvY7nbQ0OIo2+jXc4Tb8u0qCrc mamX9kChU6qhTVZwFrj9IO0eM+5drUPU9yUINKxrd9/YsNCa6SXWboGDoDwLUG0YJu1l uazg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:arc-authentication-results; bh=7ERxlCtQ7raWrgfd2AWPKysm7udhjObxGuPvj/qZOmw=; b=Iesr+AEU2LTGjTMHsD7S/Ytu2bnuEY/c1kTcwk9FbmOUAQ4vPVBwTkhZXarphOiOId Jn7nF70oKK11zE1p366I89SeY4N0KoXJW0sMGn4vjf/RoWH6rmgZv315c5tlBc8Yq7ja rRMCA+PelK7Z1TIcN0bjv1YXgdrXDpfRTkqGk2hHSBn7UfF8qjAc7qx6wh/Acl7G8kfu RPf03MFiyzce4/nDrd29FCboeFv6WOxeMaMvfF+O4xWzSKapaEYjo5v1rALRhf+zoYqq +zBO4sj+zo6DjVoI0WNIjohTIxSlWLRdOnf41DoU5XzD01msqWyCawvBTkcrEy4q0Ys1 JqPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@CAVIUMNETWORKS.onmicrosoft.com header.s=selector1-cavium-com header.b=TfD46ugf; 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 f2si711700pln.794.2017.08.20.03.22.15; Sun, 20 Aug 2017 03:22:15 -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; dkim=pass header.i=@CAVIUMNETWORKS.onmicrosoft.com header.s=selector1-cavium-com header.b=TfD46ugf; 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 S1752768AbdHTKWN (ORCPT + 26 others); Sun, 20 Aug 2017 06:22:13 -0400 Received: from mail-sn1nam02on0071.outbound.protection.outlook.com ([104.47.36.71]:22608 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752344AbdHTKWL (ORCPT ); Sun, 20 Aug 2017 06:22:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=7ERxlCtQ7raWrgfd2AWPKysm7udhjObxGuPvj/qZOmw=; b=TfD46ugfHhPyyAWCvlGGyuFqLyyS3yw99WbXi04GmjybkLHSHR66iAZaqh+bnCNTwgBHUjRjsRAgGqW4coJjsutEyZ4Cgo71Omci68I4LJleX2/ZBnlI8kMp9124D5X8SjHhY7Z054BBpkvx1BmJDJ3RivKyq5mW7UTVlDeovls= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@cavium.com; Received: from localhost (88.148.44.109) by SN1PR07MB2128.namprd07.prod.outlook.com (10.164.46.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1362.18; Sun, 20 Aug 2017 10:22:07 +0000 From: Yury Norov To: Catalin Marinas , Pratyush Anand Cc: Yury Norov , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] arm64: cleanup {COMPAT_,}SET_PERSONALITY() macro Date: Sun, 20 Aug 2017 13:20:48 +0300 Message-Id: <20170820102048.7537-3-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170820102048.7537-1-ynorov@caviumnetworks.com> References: <20170820102048.7537-1-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [88.148.44.109] X-ClientProxiedBy: HE1PR06CA0144.eurprd06.prod.outlook.com (10.170.251.31) To SN1PR07MB2128.namprd07.prod.outlook.com (10.164.46.158) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c0333e8c-f401-4f52-9b35-08d4e7b5504e X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:SN1PR07MB2128; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2128; 3:DQbTM027e9WcY2QD435swqDoj2sCP2n0C+lMbeEnMNFlIL+kqmroVJkvGPBYxP9juL9wKjz+j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pGeEde+Z9RZ/XO7HnJlWwU6RR1Un6czUY5FqePd4yh9JLB98xJs65m0r/XcCod4aUXHwAjjYO+7a5i5N5USIHUSHdwx7oLK+lJyxMGQ302F8BdxD0O7OUZWQpswImHh8L9Q18HoqHLjI9FdnaGkotKWMkhQ237B+3tuxSfAIgaS0Gtu+R/fDWicTsntXzGfkpvj0H7jouax44DlicDUS+FeyCdr51NEC5Q118NhG4wmheH3kbgzsuLYkspRp/0p+eD5j2G/Uy4SXtWkbXyryi3LNVM0ELAEc0FnFN45ChEnodNYk/WvR9X7rvFMi0USirvuHQjvH4RZ/ObenCx2Lj0vtpkON2QEkafUzsw05MCZNzog=; 4:HVzTkm7IT3cr8oCXp0Ki3bxF4lKoEyFhkEYS0dMEvU2bY2AZvxJ7jhwLzkBcrVwayVGcSZohvGe/Tt9HYywQfxa9uF2inMP58X6ddFEF1bUuMXKTWHmWonWXsApKMd/aLWDIewtjUAENl7WkNu09VhBCN4/winB2nH+Nroqir8RzV6b7U0D69gWLOewruKujZalMPl7vmhJmBKl+tw72zolk4S1mYVnLQveJ4MAI4LBBBDnIGKT7tUeWNtUqzu4y1DyKJw64eS88iHwb25dRa5N0goPorijcb5FHeFlytvs= X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(100000703101)(100105400095)(93006095)(10201501046)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123555025)(20161123560025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR07MB2128; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR07MB2128; X-Forefront-PRVS: 040513D301 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(6069001)(199003)(189002)(6306002)(101416001)(105586002)(6486002)(4326008)(42186005)(25786009)(6496005)(50986999)(76506005)(76176999)(53936002)(48376002)(2906002)(3846002)(6116002)(50466002)(478600001)(106356001)(42882006)(6666003)(2950100002)(36756003)(1076002)(7350300001)(33646002)(5003940100001)(305945005)(68736007)(7736002)(966005)(72206003)(189998001)(81166006)(81156014)(8676002)(66066001)(97736004)(50226002)(47776003)(5660300001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR07MB2128; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2128; 23:tPhiRkBntpakB62I96ikdXDitguAYIWeL1ycVut26Ii3F4Smqy3mRgInvkOsixpBYsIRQmjLr7egTqus9uHe/REd8p7fij7tLZKLh53USe6UrXilJiQOKjQWzrHJyj1bc15bNqDctix8fdPmjeLbyfyYylYce6l9TrUj+Q31MpnOLv5+s9Z1fydWpaBAunPvOaEJtM8lOt1zHBirjClZmUQ/YEa0iQSOqeaXLB4Opq7wIWEMJ7A6TFZH3Y4nQxwylJsHaDcnjL4p6tq8U51+Y8h/43mRXX/XiFpn+Ja9la0w1uc8OGEb2Rm5ku8C/vy+MGInYs7Jp3VoNbWs3ninMWLiajOAt0te1DWdCAQ7LXN8oPvCNLenHm1cMK9uRm9TOKOc+UrJd5cuAubtBIlJbWeLAdQ7b5+3kgGsglsa49YhrV3C1hZs8YzIIdddA+z525QN4zxaXdwwdhSNGimCKBNXQwtViPOL89Ky7eoiQy3qlD1D2j24t32yTElExZ1u/3NomWQo0CItz1miTntWxsTIKd0r6znV6xOuuaXRygMJCXiQOKUMEsbKzXihnZjh43DWABZLy2datuSMr/3ZnxWx2mHhOhT+vYr+jF2JDAWhj3dggl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4UqoZQ6hAEyuBMtkcrfOCgts1vjsS97Y1fakhV2rk+2HkNfIdcp4tss4ZpUjE4qFXijfKTas2yX6ZlDr/03Zw+sxdvnOFUEd21Rs=; 7:RkKfSi4cykq3ECcNea4yrclj1FRRa2d1uPAtr3DmM8Yj9IhNf60UNtcsb4b+LpI2XJ9KgrH/Nm5t5O5toQjxuOVNWR29/aE1mKoPNPXyLJzMb53vBBSLOMRKQ276Ywx6rFBhZoj2aMPw9a7VSbUAh8iz+QfsYBbx6AW9fIy4uRaWQoP6o7LB7E0VmZICYBIKokXsMU18eRd97Ni0qltjqM1V+jWscUEmEgsZJQ5X3kA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2017 10:22:07.8351 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR07MB2128 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is some work that should be done after setting the personality. Currently it's done in the macro, which is not the best idea. In this patch new arch_setup_new_exec() routine is introduced, and all setup code is moved there, as suggested by Catalin: https://lkml.org/lkml/2017/8/4/494 v2: - don't move clearing READ_IMPLIES_EXEC flag from SET_PERSONALITY() Signed-off-by: Yury Norov CC: Pratyush Anand CC: Catalin Marinas --- arch/arm64/include/asm/elf.h | 7 +++++-- arch/arm64/include/asm/thread_info.h | 3 +++ arch/arm64/kernel/process.c | 8 ++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) -- 2.11.0 diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index 517b9ff0456c..9c4434b8a9a8 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -137,9 +137,13 @@ typedef struct user_fpsimd_state elf_fpregset_t; */ #define ELF_PLAT_INIT(_r, load_addr) (_r)->regs[0] = 0 +/* + * Don't modify this macro unless you add new personality. + * All personality-related setup should be done at proper place. + * If not sure, consider the arch_setup_new_exec() function. + */ #define SET_PERSONALITY(ex) \ ({ \ - current->mm->context.flags = 0; \ clear_thread_flag(TIF_32BIT); \ current->personality &= ~READ_IMPLIES_EXEC; \ }) @@ -195,7 +199,6 @@ typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG]; */ #define COMPAT_SET_PERSONALITY(ex) \ ({ \ - current->mm->context.flags = MMCF_AARCH32; \ set_thread_flag(TIF_32BIT); \ }) #define COMPAT_ARCH_DLINFO diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h index 46c3b93cf865..c823d2f12b4c 100644 --- a/arch/arm64/include/asm/thread_info.h +++ b/arch/arm64/include/asm/thread_info.h @@ -68,6 +68,9 @@ struct thread_info { #define thread_saved_fp(tsk) \ ((unsigned long)(tsk->thread.cpu_context.fp)) +void arch_setup_new_exec(void); +#define arch_setup_new_exec arch_setup_new_exec + #endif /* diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 659ae8094ed5..e99012c4803a 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -417,3 +417,11 @@ unsigned long arch_randomize_brk(struct mm_struct *mm) else return randomize_page(mm->brk, SZ_1G); } + +/* + * Called immediately after a successful exec. + */ +void arch_setup_new_exec(void) +{ + current->mm->context.flags = is_compat_task() ? MMCF_AARCH32 : 0; +}