Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752767AbdHTKWN (ORCPT ); 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 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@cavium.com; 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 Content-Type: text/plain 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+j3OSWTde6n0g5A7oc0J56e8m/747DF+K6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UY5FqePd4yh9JLB98xJs65m0r/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; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN1PR07MB2128;23:tPhiRkBntpakB62I96ikdXDitguAYIWeL1ycVut26?= =?us-ascii?Q?Ii3F4Smqy3mRgInvkOsixpBYsIRQmjLr7egTqus9uHe/REd8p7fij7tLZKLh?= =?us-ascii?Q?53USe6UrXilJiQOKjQWzrHJyj1bc15bNqDctix8fdPmjeLbyfyYylYce6l9T?= =?us-ascii?Q?rUj+Q31MpnOLv5+s9Z1fydWpaBAunPvOaEJtM8lOt1zHBirjClZmUQ/YEa0i?= =?us-ascii?Q?QSOqeaXLB4Opq7wIWEMJ7A6TFZH3Y4nQxwylJsHaDcnjL4p6tq8U51+Y8h/4?= =?us-ascii?Q?3mRXX/XiFpn+Ja9la0w1uc8OGEb2Rm5ku8C/vy+MGInYs7Jp3VoNbWs3ninM?= =?us-ascii?Q?WLiajOAt0te1DWdCAQ7LXN8oPvCNLenHm1cMK9uRm9TOKOc+UrJd5cuAubtB?= =?us-ascii?Q?IlJbWeLAdQ7b5+3kgGsglsa49YhrV3C1hZs8YzIIdddA+z525QN4zxaXdwwd?= =?us-ascii?Q?hSNGimCKBNXQwtViPOL89Ky7eoiQy3qlD1D2j24t32yTElExZ1u/3NomWQo0?= =?us-ascii?Q?CItz1miTntWxsTIKd0r6znV6xOuuaXRygMJCXiQOK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z4oYulFnzml2iwBYqkpaYFYUX3fWMgyz+Mlg==;5:tJne3fA5/PK+UwnelgWbl9W5BJzcIs3tuoyfuFYuYktLgtiP4zaAcz/lXnAkc8A2zg2pVfuWK2nXaJcg4K78Mo07hZVmi0Cu+1l6jAOfqysvbcATrDeiPDkx5lEd32qCyEsnyqOkqM9R0x1lCc/azw==;24:vY/3ede4UqoZQ6hAEyuBMtkcrfOCgts1vjsS97Y1fakhV2rk+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 List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2590 Lines: 78 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(-) 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; +} -- 2.11.0