From patchwork Tue Sep 29 22:14:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 54272 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id 5B77822B1E for ; Tue, 29 Sep 2015 22:19:27 +0000 (UTC) Received: by laer8 with SMTP id r8sf11522986lae.2 for ; Tue, 29 Sep 2015 15:19:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-type :spamdiagnosticoutput:spamdiagnosticmetadata:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe; bh=MocZUZjtGphoP9SOVYZ08wshBcSow2qIRTUsOgkH6G0=; b=R66W5cSCGUv9z31Sv3ZIkxn0V4KOnWuGDWRe6vNJgxvTK62EkiBg4phuUxDkgw0uBO PSEHkjnWzXQ9+/l+NKvNXLoHGU5ObZS0GgORGZpQ4+CB7cFiWgYL0bws2tywzAa4DO7P 0cmHrTF/5/5WimWPZFtTym/oFSdJ6Uu8onPhzdKivbsDlxssSuiRFFArXVf8fFCiVH8Z wfuqAousEl4mSZn/VmnrT7AAn/78HXqKC2ed6ZzuZVAOlZ680LfV8o6S+whtVp0SMS/z 23UdPdZ1CitxEbC/QPd1VEwCFwIaE9UdxNHDj1m78gz2Bgteo87gKXw9H6qWNcTTmg3B Pk1w== X-Gm-Message-State: ALoCoQkgEtoJIE7j0nOOkQfpIhSfrVnBd4VjGfnTp7wHvXLWnm1MI4FMrqE7yplRECgOG65zOf8b X-Received: by 10.152.170.169 with SMTP id an9mr48070lac.2.1443565166220; Tue, 29 Sep 2015 15:19:26 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.86.70 with SMTP id k67ls5821lfb.43.gmail; Tue, 29 Sep 2015 15:19:25 -0700 (PDT) X-Received: by 10.112.180.198 with SMTP id dq6mr101763lbc.90.1443565165934; Tue, 29 Sep 2015 15:19:25 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id pf6si11937865lbc.166.2015.09.29.15.19.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Sep 2015 15:19:25 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by lahh2 with SMTP id h2so25540916lah.0 for ; Tue, 29 Sep 2015 15:19:25 -0700 (PDT) X-Received: by 10.25.82.10 with SMTP id g10mr70988lfb.56.1443565165802; Tue, 29 Sep 2015 15:19:25 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp2398194lbq; Tue, 29 Sep 2015 15:19:24 -0700 (PDT) X-Received: by 10.68.234.6 with SMTP id ua6mr428214pbc.145.1443565164375; Tue, 29 Sep 2015 15:19:24 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id aj8si40474508pad.206.2015.09.29.15.19.24; Tue, 29 Sep 2015 15:19:24 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933086AbbI2WTL (ORCPT + 30 others); Tue, 29 Sep 2015 18:19:11 -0400 Received: from mail-bn1on0077.outbound.protection.outlook.com ([157.56.110.77]:53649 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754540AbbI2WR6 (ORCPT ); Tue, 29 Sep 2015 18:17:58 -0400 Received: from localhost (91.78.158.8) by CO2PR07MB619.namprd07.prod.outlook.com (10.141.228.151) with Microsoft SMTP Server (TLS) id 15.1.274.16; Tue, 29 Sep 2015 22:17:55 +0000 From: Yury Norov To: , , , , , CC: , , , , , Yury Norov Subject: [PATCH v5 16/23] arm64: add support for starting ILP32 (ELFCLASS32) binaries Date: Wed, 30 Sep 2015 01:14:13 +0300 Message-ID: <1443564860-31208-17-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1443564860-31208-1-git-send-email-ynorov@caviumnetworks.com> References: <1443564860-31208-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [91.78.158.8] X-ClientProxiedBy: DB5PR02CA0001.eurprd02.prod.outlook.com (25.161.237.11) To CO2PR07MB619.namprd07.prod.outlook.com (10.141.228.151) X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB619; 2:h9D94WaYOILGwwBUqq9nTz9GQZiwc4s+PnFaqXPOMwfuOQ0kKbEJIwZrb1CqLuEwjjubQLE71HmM9fNKCUL93SKgANmoa2d0A9IhaYkNQLuFhVYDgI561XA9G2TG3usI27MPZB54oiZXf/moqM8nMQtBC5RR5oIcgo+Oh18TW24=; 3:q9JSy449cckrurTErevR5OpXo1096cuTGf/BD5K9W+coS3m2SXObpCam/YdcNJQ84YepySCeink3ly36fhZt4awRW61vspn+hMdPFBhAlyLRFKUhf5wvNs9xbcVKQ2Bfkh7hw8oyrTLNXh8Y7G19NQ==; 25:2x9Hj3UO8rgqA/rz9J9HiuOujD1s61TAv2UUlRf3PR70KCEscZEapD4Q93txhdU4au5dDQmWI5tiMVAQQ/gu9Mn5T3fHNYnFKzqziKARSUNx1Y2+BPZnP0d8zMufuQ2EtSNahzSJnUU9FrdUEp1q03fUOcn1TSfOhAvinOGm1Jbfy0AnugI8Xkx71F6n+V3cDYlEtqU+tRYijKj/zEEI2BeQVlhh8AClh1JfNP3FObr1c42NVjvEOmx5SgmszjbPlC187CUFrw5tnIgBFPYdug== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CO2PR07MB619; X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB619; 20:/RGaSzrSu9d459HO5F6AvxGPVMlw6vbdaX/C9u4sYf9Spg2JjI//ldZro87y9BBgPOoyEIAXZj+qlPbdG3Hq1i9xdg34YdpQ+6s4f7rZCWOBQDKDBtBTN35l5IzwzQO/gWsi15Afp5xL1M6JqSvr/en2CMoYcCzwYEMAEUlmzbTeXRAnJxDUenUhjfcjP4azLoF2V3izimfJnqPAM+bvNA6IRXUIogUHOJ0PozrNPeLHuzQDVvMHidC35ypTnpC56n321NEsw4yj8EfFcOW6xVVmolcx6OC5vImzI6GqHTz85xyFXH3k373ZKs4dr43RdJeKJuIqLdgErwAhZMKPacl8mhDyqTKBESpbLo8RbR2V3d8ubVK5hp7q0q065BUZ81fY2xqCTGdiTdQ0X56Ozwn1yI1EkKUrD88tdBJaNhJZjl3Ivzqc4BCkdt5wrLWzMu+9lK0kpzEqQTgUId5PxTX3Ept0ZgqRa7h+f71DmJNSbrRpM5+MaTfnVYqaEuC1OaGWLPPjefVYBwymZ6p5TLUHGidDv7jrYtsIkEtiP8ZZqqu7HCu/AJuDXNhidWv8gKFE6ZUO9RpB2v3u9xzCy3DzEinSJINO0a+z+qcenRc= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(8121501046)(5005006)(3002001); SRVR:CO2PR07MB619; BCL:0; PCL:0; RULEID:; SRVR:CO2PR07MB619; X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB619; 4:k8i/qSQTMUsREzfWZPjJCM2037VWJSXN7KxqmqM7sGT8KMo47qQAIOZVmzRRD+nq6hOJRRfOPc06rIdUH8jBYwePzKK+fCYysQOD/cNsGO/Y0DnJEqzpEZKMCUE2P0TYUjMOPwm6AqqOuVYDHy8ovIOtOf2u4gh9PZe0HGXoiWXvFigS2bU1h6TAi689gPfaXykgVgu1irWyTGDg6WopXHrZI/JUiytVKnVKJNhtT/Z4BC4g416NMm0vfHmtTY2ZvfvMBIwrEm0GPPBjQTRebvewgpCZ/L+Hk+D/DUQVNdEUh44gb1omQ1IPr5PphrgxeYO+WgQ8T6OedtT1DAOh75PgBB1QcwaxM1YgAkLDMtk= X-Forefront-PRVS: 0714841678 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(189002)(199003)(42186005)(66066001)(50466002)(64706001)(122386002)(2950100001)(48376002)(47776003)(5008740100001)(77156002)(46102003)(33646002)(68736005)(97736004)(5001770100001)(62966003)(92566002)(5001860100001)(50986999)(189998001)(5001920100001)(4001540100001)(101416001)(5007970100001)(40100003)(5001960100002)(2201001)(105586002)(5003940100001)(5001830100001)(76506005)(87976001)(81156007)(229853001)(106356001)(19580395003)(19580405001)(5004730100002)(76176999)(107886002)(50226001)(77096005)(36756003)(4001430100001)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR07MB619; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: caviumnetworks.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO2PR07MB619; 23:0RVsJIsAwHMPCih/ZefltT/fuLmgB54A/zQXwltrrD?= =?us-ascii?Q?U+9hZxAQNvER6+iTxGEOhtzNF9YYfAkwTxy7T2yZvg4eMHaVfspB4uI4vXAt?= =?us-ascii?Q?cN/BUrWelE3wI6uZrkiywC1D7g2epNH7xtKYZq2V9Ol4I4iIlhG9TnK1X/r+?= =?us-ascii?Q?oc/ELJhmn4/rYVku+UFtsAx7yNPes9VQPKHkPRha8Ds7psbxVYH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JiJHix60J2gXcKH4nr9L5vHqU99U6CkLrQhKiUk6UyUyg?= =?us-ascii?Q?E9sPGyiTZZBB6gzj7w0Ph3UVdpIn0wEzOsCuWtzPfLveCOE5u//uOW2wNcoP?= =?us-ascii?Q?QrKdBNi8Mwasdh3rjh3UvZvyOQUAElhChZdNyI2W0byfHNgadWDTGuzoAvCU?= =?us-ascii?Q?TirbJu3L958sXgrwFc9o7pxB7EV/lMA5g6RRR/LiSS/ZDEOF+KAgPx6yERyS?= =?us-ascii?Q?mL1x/gYpYatdnOVwKjiQ4TQvPwmUl+0JpJe1k5o3rJ?= X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB619; 5:p/VsA86YTaE4IayXiiUnVjnEhSNVFNp1WBBUjg77EA/Rs8Jm0da2E0O2nNnzhH6oKwbgFwefpr5ql9m9obsxcq8HKMGCMbbfeabdO7j+082lkw/FskmxL1mZVGCGWtRtmxihc/dCReUmFRapMOXuxQ==; 24:6M9KLORCfg6rhnEFyaPC2KCiFBeVCjHWAq0B6lT2dbiRMtz78OUw6WZxj4oNdKnbrOTVKQ4L8k+XIbDOjAIhG8dMwS1Q+yxXmzKR0MA4TS0=; 20:TJyFCzfugs8qaPBsDb/zFGJ8pBSj8CK9mW08ozCvejwOKwc7aInXwTwgd2g6viMePv4aWzYl5CTbIpF3Reqssw== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2015 22:17:55.3772 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR07MB619 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linux-kernel-owner@vger.kernel.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Andrew Pinski Handle ILP32 (AArch64, but ELFCLASS32) binaries on ARM64. Signed-off-by: Philipp Tomsich Signed-off-by: Christoph Muellner Signed-off-by: Yury Norov diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index d4d53c91a..9a854f9 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -134,7 +134,11 @@ typedef struct user_fpsimd_state elf_fpregset_t; */ #define ELF_PLAT_INIT(_r, load_addr) (_r)->regs[0] = 0 -#define SET_PERSONALITY(ex) clear_thread_flag(TIF_32BIT); +#define SET_PERSONALITY(ex) \ +do { \ + clear_thread_flag(TIF_32BIT_AARCH64); \ + clear_thread_flag(TIF_32BIT); \ +} while (0) #define ARCH_DLINFO \ do { \ @@ -167,6 +171,9 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm, #define COMPAT_ELF_ET_DYN_BASE (2 * TASK_SIZE_32 / 3) +extern int aarch32_setup_vectors_page(struct linux_binprm *bprm, + int uses_interp); + #ifdef CONFIG_AARCH32_EL0 /* AArch32 registers. */ @@ -176,27 +183,23 @@ typedef compat_a32_elf_greg_t compat_a32_elf_gregset_t[COMPAT_A32_ELF_NGREG]; /* AArch32 EABI. */ #define EF_ARM_EABI_MASK 0xff000000 -#define compat_elf_check_arch(x) (((x)->e_machine == EM_ARM) && \ +#define compat_a32_elf_check_arch(x) (((x)->e_machine == EM_ARM) && \ ((x)->e_flags & EF_ARM_EABI_MASK)) #define compat_start_thread compat_start_thread -#define COMPAT_SET_PERSONALITY(ex) set_thread_flag(TIF_32BIT); -#define COMPAT_ARCH_DLINFO - - -extern int aarch32_setup_vectors_page(struct linux_binprm *bprm, - int uses_interp); -#define compat_arch_setup_additional_pages \ - aarch32_setup_vectors_page +#define COMPAT_A32_SET_PERSONALITY(ex) \ +do { \ + clear_thread_flag(TIF_32BIT_AARCH64); \ + set_thread_flag(TIF_32BIT); \ +} while (0) +#define COMPAT_A32_ARCH_DLINFO do {} while (0) #else - typedef elf_greg_t compat_elf_greg_t; typedef elf_gregset_t compat_elf_gregset_t; #define compat_a32_elf_check_arch(x) 0 -#define COMPAT_SET_PERSONALITY(ex) -#define COMPAT_ARCH_DLINFO - +#define COMPAT_A32_SET_PERSONALITY(ex) do {} while (0) +#define COMPAT_A32_ARCH_DLINFO do {} while (0) #endif /* If ILP32 is turned on, we want to define the compat_elf_greg_t to the non compat @@ -217,7 +220,46 @@ typedef compat_a32_elf_greg_t compat_elf_greg_t; typedef compat_a32_elf_gregset_t compat_elf_gregset_t; #endif -#define compat_elf_check_arch(x) compat_a32_elf_check_arch(x) +#ifdef CONFIG_ARM64_ILP32 +#define compat_ilp32_elf_check_arch(x) ((x)->e_machine == EM_AARCH64) +#define COMPAT_ILP32_SET_PERSONALITY(ex) \ +do { \ + set_thread_flag(TIF_32BIT_AARCH64); \ + clear_thread_flag(TIF_32BIT); \ +} while (0) +#define COMPAT_ILP32_ARCH_DLINFO \ +do { \ + NEW_AUX_ENT(AT_SYSINFO_EHDR, \ + (elf_addr_t)(long)current->mm->context.vdso); \ +} while (0) +#else +#define compat_ilp32_elf_check_arch(x) 0 +#define COMPAT_ILP32_SET_PERSONALITY(ex) do {} while (0) +#define COMPAT_ILP32_ARCH_DLINFO do {} while (0) +#endif + +#define compat_elf_check_arch(x) (compat_a32_elf_check_arch(x) || compat_ilp32_elf_check_arch(x)) +#define COMPAT_SET_PERSONALITY(ex) \ +do { \ + if (compat_a32_elf_check_arch(&ex)) \ + COMPAT_A32_SET_PERSONALITY(ex); \ + else \ + COMPAT_ILP32_SET_PERSONALITY(ex); \ +} while (0) + +/* ILP32 uses the "LP64-like" vdso pages */ +#define compat_arch_setup_additional_pages \ + (is_a32_compat_task() \ + ? &aarch32_setup_vectors_page \ + : &(arch_setup_additional_pages)) + +#define COMPAT_ARCH_DLINFO \ +do { \ + if (is_a32_compat_task()) \ + COMPAT_A32_ARCH_DLINFO; \ + else \ + COMPAT_ILP32_ARCH_DLINFO; \ +} while (0) #endif /* CONFIG_COMPAT */ diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c index 26352a6..b239b9b 100644 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c @@ -107,6 +107,14 @@ int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp) return PTR_ERR_OR_ZERO(ret); } +#else +int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp) +{ + (void) bprm; + (void) uses_interp; + + return -EINVAL; +} #endif /* CONFIG_AARCH32_EL0 */ static struct vm_special_mapping vdso_spec[2];