From patchwork Fri Oct 4 18:52:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 11175207 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1706815AB for ; Fri, 4 Oct 2019 18:54:38 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 883EC2053B for ; Fri, 4 Oct 2019 18:54:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZHghVU8s"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b="GUvNg6jo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 883EC2053B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=soleen.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WN5jJniGPP0yJ8LXg7I7sIiNnDGzciFHcX/9FqggTcc=; b=ZHghVU8sruj1MJ ScWeSXEU8IW3vJeJ2QG9bQ4SCWIp8LfVflR1TcChNCVtuTjMJokTxJ7bDe7WF/4lRK8B8B/q0BvK5 slDpwhTgTUrYIF8diUFEqtw3xCMogYVq/0zH3VaxE20sI0V7/dP44tKty1Mpn/uDCDNkBiU+xCfjF u0h/vfIQBhnHYnrGt8vfJWkwh63v99yB49DgHwmj3JHkoXQWUG1+BcOQLkp+qzAqemyz4jEktwpt7 /iodkAtyMOj8AIHtFXGkcRc6RMcGAKz+6AMBuZ7BHXNwNL52r2ET5/R9eMj7yEG2PJ70XEwlV+2ye 1GJoEFi4xRiuFeAyPGJw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iGSio-0003rZ-2m; Fri, 04 Oct 2019 18:54:34 +0000 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iGSh1-00025o-W9 for linux-arm-kernel@lists.infradead.org; Fri, 04 Oct 2019 18:52:46 +0000 Received: by mail-qt1-x844.google.com with SMTP id n7so9928672qtb.6 for ; Fri, 04 Oct 2019 11:52:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=MH284WpfdMmTT4sRM0t5AqX3XpYou6gu7tWPymm7DjQ=; b=GUvNg6jopwQGdtg/6ePwW8FAdf2hNTcU05Us5Ku9cjDRWtI/aX3LtJgojOl96T0rvI 8LgF/QgW/zbrgtvze1t2wa9uO8f9GbMxGTNWh36/LsNDdB3d5IGhAkBgyIafPWNksQWZ 965mdDyUaKF23rg4al5Lprl7RJ6IVv3fc0Wvhg5uurlJV82h+UVIJHmL/tYR/2X0Scbg Th0h0XqRmAcQfHvex+H6FrOSADKthVLIb/ZK3rObXqj6VQU2PYdFcqlmwX2ZSNC1U7U7 vW6TnWWA9sJaeYC90L0SSQcpMBA7VVjAgIQHqmHLkSrywolOmPQ/EcrcucSYUn0iAdte KXog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MH284WpfdMmTT4sRM0t5AqX3XpYou6gu7tWPymm7DjQ=; b=luZ2k/mPu9szcQHXpvK6W0fKQ4GgvvDw6g3pOKPE9muBr6iVimAHi4hcHH2sYW3/1Z 96NAptlyF0ZomlvTSVnc+BJHjzEk+IS3NWtb0Amot4qQBH38EwPmAAcD5gAycjEBNCb/ I6+A3dR949F9JSRNCtYuol/DKjuVYccIMJumkLJnUuQ4uzLKOKIURRDp7024dg8a3v0U 6Yt13cYK1weaF6yJ/3VO2Yjrl+/WnicvZxMKfo1PgjBfxa6leTQQLsGK8sJ+SG1RHArT bftTEpMmwKwwRNYRAGLzeYwVCot6H5X97wBaOC7ILlKSxaHmo6tcTSz1DAQiOtT/Y779 gjpQ== X-Gm-Message-State: APjAAAVonjBHIClnzaLYxXDaUdFVTZlZMJG7oioQbiXxcRYtJFoxcIta 9RBlJRQY97qZPJs74nR9Zde95g== X-Google-Smtp-Source: APXvYqxavVqgxdLnADEh3PhfJBun5BtV1W9q5NOyxxlklwh/d5zn3dU2h1jwYR4ZDVr0URe21Lpnpw== X-Received: by 2002:ac8:3876:: with SMTP id r51mr17961871qtb.66.1570215163109; Fri, 04 Oct 2019 11:52:43 -0700 (PDT) Received: from localhost.localdomain (c-73-69-118-222.hsd1.nh.comcast.net. [73.69.118.222]) by smtp.gmail.com with ESMTPSA id p77sm4042514qke.6.2019.10.04.11.52.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2019 11:52:42 -0700 (PDT) From: Pavel Tatashin To: pasha.tatashin@soleen.com, jmorris@namei.org, sashal@kernel.org, ebiederm@xmission.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, corbet@lwn.net, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, marc.zyngier@arm.com, james.morse@arm.com, vladimir.murzin@arm.com, matthias.bgg@gmail.com, bhsharma@redhat.com, linux-mm@kvack.org, mark.rutland@arm.com Subject: [PATCH v6 04/17] arm64: hibernate: use get_safe_page directly Date: Fri, 4 Oct 2019 14:52:21 -0400 Message-Id: <20191004185234.31471-5-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191004185234.31471-1-pasha.tatashin@soleen.com> References: <20191004185234.31471-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191004_115244_082386_A1845B5B X-CRM114-Status: GOOD ( 11.96 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:844 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org create_safe_exec_page() uses hibernate's allocator to create a set of page table to map a single page that will contain the relocation code. Remove the allocator related arguments, and use get_safe_page directly, as it is done in other local functions in this file to simplify function prototype. Removing this function pointer makes it easier to refactor the code later. Signed-off-by: Pavel Tatashin Reviewed-by: Matthias Brugger --- arch/arm64/kernel/hibernate.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c index ef46ce66d7e8..34297716643f 100644 --- a/arch/arm64/kernel/hibernate.c +++ b/arch/arm64/kernel/hibernate.c @@ -196,9 +196,7 @@ EXPORT_SYMBOL(arch_hibernation_header_restore); */ static int create_safe_exec_page(void *src_start, size_t length, unsigned long dst_addr, - phys_addr_t *phys_dst_addr, - void *(*allocator)(gfp_t mask), - gfp_t mask) + phys_addr_t *phys_dst_addr) { int rc = 0; pgd_t *trans_pgd; @@ -206,7 +204,7 @@ static int create_safe_exec_page(void *src_start, size_t length, pud_t *pudp; pmd_t *pmdp; pte_t *ptep; - unsigned long dst = (unsigned long)allocator(mask); + unsigned long dst = get_safe_page(GFP_ATOMIC); if (!dst) { rc = -ENOMEM; @@ -216,7 +214,7 @@ static int create_safe_exec_page(void *src_start, size_t length, memcpy((void *)dst, src_start, length); __flush_icache_range(dst, dst + length); - trans_pgd = allocator(mask); + trans_pgd = (void *)get_safe_page(GFP_ATOMIC); if (!trans_pgd) { rc = -ENOMEM; goto out; @@ -224,7 +222,7 @@ static int create_safe_exec_page(void *src_start, size_t length, pgdp = pgd_offset_raw(trans_pgd, dst_addr); if (pgd_none(READ_ONCE(*pgdp))) { - pudp = allocator(mask); + pudp = (void *)get_safe_page(GFP_ATOMIC); if (!pudp) { rc = -ENOMEM; goto out; @@ -234,7 +232,7 @@ static int create_safe_exec_page(void *src_start, size_t length, pudp = pud_offset(pgdp, dst_addr); if (pud_none(READ_ONCE(*pudp))) { - pmdp = allocator(mask); + pmdp = (void *)get_safe_page(GFP_ATOMIC); if (!pmdp) { rc = -ENOMEM; goto out; @@ -244,7 +242,7 @@ static int create_safe_exec_page(void *src_start, size_t length, pmdp = pmd_offset(pudp, dst_addr); if (pmd_none(READ_ONCE(*pmdp))) { - ptep = allocator(mask); + ptep = (void *)get_safe_page(GFP_ATOMIC); if (!ptep) { rc = -ENOMEM; goto out; @@ -530,8 +528,7 @@ int swsusp_arch_resume(void) */ rc = create_safe_exec_page(__hibernate_exit_text_start, exit_size, (unsigned long)hibernate_exit, - &phys_hibernate_exit, - (void *)get_safe_page, GFP_ATOMIC); + &phys_hibernate_exit); if (rc) { pr_err("Failed to create safe executable page for hibernate_exit code.\n"); goto out;