Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1865106ybd; Sun, 23 Jun 2019 18:42:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxknjpbjxvxtURR+xxfnShUVK3ufvEntnjM1W10b46T/Jr1C1JXsnuS0gNs/h0NJ/+aZUha X-Received: by 2002:a17:902:2ac8:: with SMTP id j66mr100520672plb.273.1561340530455; Sun, 23 Jun 2019 18:42:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561340530; cv=none; d=google.com; s=arc-20160816; b=E6MEPlrLTrsAPVnFQKlBGV8r2BdF9POL0oQlXXrhrgJVKiFQCvh4nlvI7jo9G7Gk9f ep6KOgqiob2t3sKsSynff89ZCiqh2BCYzNrcGnA+Dbw/ur7kD5jMpO2B4OAYP/9FdIEL MiirkYGmHX0jqQf6KgTyp/xJ+a9jWXBSA9LpZx/I80EE1OTREmYTL0H/TKrT17XoVjzb F3ZciYs5rVyYpyU2G0u/MyWabigP5kxVgth4yOEBD7s/5wSASGgwSWQM3aV00QGdPmwt Qtiwp4qkUXdfUWKiVgIFE1dDEK67H6OimnOihusgLjjf5wMUYYUaggBI1NByN0838Pzs UIlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=BxzixoOusyzFB5MfBVCb4Q2TYJ4MTWYTpifuKqW+23I=; b=qHkJllV13iT2LfzAk9pA5+BFZwuix7Uzx/u77QTTNuqYJ7YUazase/G9uwYPlvxD0/ kC7zDXYmkQ6hjCcsyJhqPihYyQR9RaFfOBW47xK1+RZT+Aw6dg9stq/KDQ0QOdyZA4M6 zEfy5YeYJT5EvLMsaXAgmgV8b94lktTfOJ4LalD11QKO6c2xq1Rh/kYsreY5wzfZv1Xn BFbAT4ZRnDZPjyNuJ1yxoK88Q3h5TStZ3lj+nmNUkpaK+V2RSXRqX2II3j77ar6jTN40 mELXB2Le6ZYrVXvnhUSKKu1YJUgNAnIXixAa8cXtJiAPGwzPSvnBSSkv5SzswzJ+sVIH 8ASg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019061801 header.b=s3500vnS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g34si9204171pld.266.2019.06.23.18.41.54; Sun, 23 Jun 2019 18:42:10 -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=@zytor.com header.s=2019061801 header.b=s3500vnS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726726AbfFXBlV (ORCPT + 99 others); Sun, 23 Jun 2019 21:41:21 -0400 Received: from terminus.zytor.com ([198.137.202.136]:43987 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726572AbfFXBk7 (ORCPT ); Sun, 23 Jun 2019 21:40:59 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x5NNqTjR2859643 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 23 Jun 2019 16:52:29 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x5NNqTjR2859643 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019061801; t=1561333950; bh=BxzixoOusyzFB5MfBVCb4Q2TYJ4MTWYTpifuKqW+23I=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=s3500vnSS78S8RykXAedTjZiUsJtE+QgTMOwrKzdKx6EMiR4w1aB7uI2P4QeyYMI5 yNvoe2719AK056h4r29LKIBF/tlrpSWzSBtejySQjbOrLEfI8X5DMYEVor4kuekV+l bp0YsoPEr3i24rYI1+cjC/5DdT6cVN5hU8yVXm9PQ7qQhny0GrS95Vn0654aVpOM8q 6QkJ3Q3aLBkdmy8najVat0GQuF9jBUFYpzITIM7PtL5CSz2mRCr/dZeWx+XTpsFySx B8MGbovCKVlqCw5lJQLCdKnj6c+AQWe6PfsNWKYIMpCWShtOs0SEg5pZFJ6LlqoHKD q4Tff/mHERj8Q== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x5NNqSB42859640; Sun, 23 Jun 2019 16:52:28 -0700 Date: Sun, 23 Jun 2019 16:52:28 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Vincenzo Frascino Message-ID: Cc: linux-kernel@vger.kernel.org, mingo@kernel.org, ralf@linux-mips.org, hpa@zytor.com, pcc@google.com, shuah@kernel.org, linux@armlinux.org.uk, will.deacon@arm.com, tglx@linutronix.de, salyzyn@android.com, sthotton@marvell.com, daniel.lezcano@linaro.org, 0x7f454c46@gmail.com, andre.przywara@arm.com, linux@rasmusvillemoes.dk, huw@codeweavers.com, arnd@arndb.de, catalin.marinas@arm.com, paul.burton@mips.com, vincenzo.frascino@arm.com Reply-To: linux-kernel@vger.kernel.org, ralf@linux-mips.org, mingo@kernel.org, hpa@zytor.com, pcc@google.com, linux@armlinux.org.uk, shuah@kernel.org, will.deacon@arm.com, tglx@linutronix.de, salyzyn@android.com, sthotton@marvell.com, daniel.lezcano@linaro.org, 0x7f454c46@gmail.com, andre.przywara@arm.com, linux@rasmusvillemoes.dk, huw@codeweavers.com, arnd@arndb.de, catalin.marinas@arm.com, paul.burton@mips.com, vincenzo.frascino@arm.com In-Reply-To: <20190621095252.32307-13-vincenzo.frascino@arm.com> References: <20190621095252.32307-13-vincenzo.frascino@arm.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:timers/vdso] arm64: compat: VDSO setup for compat layer Git-Commit-ID: 7c1deeeb01308426a27a70d5a506aa5fae66dc62 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=2.3 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_03_06,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, DKIM_VALID_EF,FREEMAIL_FORGED_REPLYTO,FREEMAIL_REPLYTO_END_DIGIT autolearn=no autolearn_force=no version=3.4.2 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 7c1deeeb01308426a27a70d5a506aa5fae66dc62 Gitweb: https://git.kernel.org/tip/7c1deeeb01308426a27a70d5a506aa5fae66dc62 Author: Vincenzo Frascino AuthorDate: Fri, 21 Jun 2019 10:52:39 +0100 Committer: Thomas Gleixner CommitDate: Sat, 22 Jun 2019 21:21:08 +0200 arm64: compat: VDSO setup for compat layer If CONFIG_GENERIC_COMPAT_VDSO is enabled, compat vDSO is installed in a compat (32 bit) process instead of sigpage. Add the necessary code to setup the vDSO required pages. Signed-off-by: Vincenzo Frascino Signed-off-by: Thomas Gleixner Tested-by: Shijith Thotton Tested-by: Andre Przywara Cc: linux-arch@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-mips@vger.kernel.org Cc: linux-kselftest@vger.kernel.org Cc: Catalin Marinas Cc: Will Deacon Cc: Arnd Bergmann Cc: Russell King Cc: Ralf Baechle Cc: Paul Burton Cc: Daniel Lezcano Cc: Mark Salyzyn Cc: Peter Collingbourne Cc: Shuah Khan Cc: Dmitry Safonov <0x7f454c46@gmail.com> Cc: Rasmus Villemoes Cc: Huw Davies Link: https://lkml.kernel.org/r/20190621095252.32307-13-vincenzo.frascino@arm.com --- arch/arm64/kernel/vdso.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 88 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c index be23efc3f60d..354b11e27c07 100644 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c @@ -29,12 +29,22 @@ #include extern char vdso_start[], vdso_end[]; +#ifdef CONFIG_COMPAT_VDSO +extern char vdso32_start[], vdso32_end[]; +#endif /* CONFIG_COMPAT_VDSO */ /* vdso_lookup arch_index */ enum arch_vdso_type { ARM64_VDSO = 0, +#ifdef CONFIG_COMPAT_VDSO + ARM64_VDSO32 = 1, +#endif /* CONFIG_COMPAT_VDSO */ }; +#ifdef CONFIG_COMPAT_VDSO +#define VDSO_TYPES (ARM64_VDSO32 + 1) +#else #define VDSO_TYPES (ARM64_VDSO + 1) +#endif /* CONFIG_COMPAT_VDSO */ struct __vdso_abi { const char *name; @@ -53,6 +63,13 @@ static struct __vdso_abi vdso_lookup[VDSO_TYPES] __ro_after_init = { .vdso_code_start = vdso_start, .vdso_code_end = vdso_end, }, +#ifdef CONFIG_COMPAT_VDSO + { + .name = "vdso32", + .vdso_code_start = vdso32_start, + .vdso_code_end = vdso32_end, + }, +#endif /* CONFIG_COMPAT_VDSO */ }; /* @@ -163,24 +180,52 @@ up_fail: /* * Create and map the vectors page for AArch32 tasks. */ +#ifdef CONFIG_COMPAT_VDSO +static int aarch32_vdso_mremap(const struct vm_special_mapping *sm, + struct vm_area_struct *new_vma) +{ + return __vdso_remap(ARM64_VDSO32, sm, new_vma); +} +#endif /* CONFIG_COMPAT_VDSO */ + /* * aarch32_vdso_pages: * 0 - kuser helpers * 1 - sigreturn code + * or (CONFIG_COMPAT_VDSO): + * 0 - kuser helpers + * 1 - vdso data + * 2 - vdso code */ #define C_VECTORS 0 +#ifdef CONFIG_COMPAT_VDSO +#define C_VVAR 1 +#define C_VDSO 2 +#define C_PAGES (C_VDSO + 1) +#else #define C_SIGPAGE 1 #define C_PAGES (C_SIGPAGE + 1) +#endif /* CONFIG_COMPAT_VDSO */ static struct page *aarch32_vdso_pages[C_PAGES] __ro_after_init; -static const struct vm_special_mapping aarch32_vdso_spec[C_PAGES] = { +static struct vm_special_mapping aarch32_vdso_spec[C_PAGES] = { { .name = "[vectors]", /* ABI */ .pages = &aarch32_vdso_pages[C_VECTORS], }, +#ifdef CONFIG_COMPAT_VDSO + { + .name = "[vvar]", + }, + { + .name = "[vdso]", + .mremap = aarch32_vdso_mremap, + }, +#else { .name = "[sigpage]", /* ABI */ .pages = &aarch32_vdso_pages[C_SIGPAGE], }, +#endif /* CONFIG_COMPAT_VDSO */ }; static int aarch32_alloc_kuser_vdso_page(void) @@ -203,7 +248,33 @@ static int aarch32_alloc_kuser_vdso_page(void) return 0; } -static int __init aarch32_alloc_vdso_pages(void) +#ifdef CONFIG_COMPAT_VDSO +static int __aarch32_alloc_vdso_pages(void) +{ + int ret; + + vdso_lookup[ARM64_VDSO32].dm = &aarch32_vdso_spec[C_VVAR]; + vdso_lookup[ARM64_VDSO32].cm = &aarch32_vdso_spec[C_VDSO]; + + ret = __vdso_init(ARM64_VDSO32); + if (ret) + return ret; + + ret = aarch32_alloc_kuser_vdso_page(); + if (ret) { + unsigned long c_vvar = + (unsigned long)page_to_virt(aarch32_vdso_pages[C_VVAR]); + unsigned long c_vdso = + (unsigned long)page_to_virt(aarch32_vdso_pages[C_VDSO]); + + free_page(c_vvar); + free_page(c_vdso); + } + + return ret; +} +#else +static int __aarch32_alloc_vdso_pages(void) { extern char __aarch32_sigret_code_start[], __aarch32_sigret_code_end[]; int sigret_sz = __aarch32_sigret_code_end - __aarch32_sigret_code_start; @@ -224,6 +295,12 @@ static int __init aarch32_alloc_vdso_pages(void) return ret; } +#endif /* CONFIG_COMPAT_VDSO */ + +static int __init aarch32_alloc_vdso_pages(void) +{ + return __aarch32_alloc_vdso_pages(); +} arch_initcall(aarch32_alloc_vdso_pages); static int aarch32_kuser_helpers_setup(struct mm_struct *mm) @@ -245,6 +322,7 @@ static int aarch32_kuser_helpers_setup(struct mm_struct *mm) return PTR_ERR_OR_ZERO(ret); } +#ifndef CONFIG_COMPAT_VDSO static int aarch32_sigreturn_setup(struct mm_struct *mm) { unsigned long addr; @@ -272,6 +350,7 @@ static int aarch32_sigreturn_setup(struct mm_struct *mm) out: return PTR_ERR_OR_ZERO(ret); } +#endif /* !CONFIG_COMPAT_VDSO */ int aarch32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) { @@ -285,7 +364,14 @@ int aarch32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) if (ret) goto out; +#ifdef CONFIG_COMPAT_VDSO + ret = __setup_additional_pages(ARM64_VDSO32, + mm, + bprm, + uses_interp); +#else ret = aarch32_sigreturn_setup(mm); +#endif /* CONFIG_COMPAT_VDSO */ out: up_write(&mm->mmap_sem);