From patchwork Fri Sep 28 06:48:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 147767 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp370844lji; Thu, 27 Sep 2018 23:48:02 -0700 (PDT) X-Google-Smtp-Source: ACcGV62v/jbhMAGOahOFViM4civsHn0RQjxgTQBKr0kEI4P1Qdp45f+nh8PVu6Oe+mh9DOBbu0im X-Received: by 2002:a17:902:9047:: with SMTP id w7-v6mr14706202plz.291.1538117282575; Thu, 27 Sep 2018 23:48:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538117282; cv=none; d=google.com; s=arc-20160816; b=To/D7yUfTjHeFmcfKs/RGZfQU/jcQaQSJ3fFzuBsp+Y5S8cEu5SsArsn09zs/BT9aT n+JDI10Zg6yaSnA73cxro20O4Zs2gWT6pmhT5krd7x6MYcrV4TWHQTEjWqJb49gXGLfq vIbLkbwDej2acMBGw2CqFCQ3q9qyP1bgwKbhc0La1mxPMOLas6BD2FJAMfjyQmBESagi xF6hjnJ+u0T7Kz+dp/Vy2hxpXzZYxNBr/ctGvyLFRUOD+YGOdA/x1X/iMdbdr7lVweGJ mCMh185mOvrS8hwgpV+65UQoBrE9N7Wl6SyO2ZDivoe0JoErxOtOhHOivvGRssBO6N2m 44nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=p7VTwSew5JIQjBLJLLspuwEGyotzVxuUjhT6Cc4QWEY=; b=DT7XYX8wfmrxO1SIG1GqoluJjf57hwLGKEfe8ZKbloZIPeBjF6pFWaVcslnU2LCUQh Mf9Q+hULYQ5q28lGyavxpTmohJTFdD6Z0dem9tASoeoRIO8Rmhs/aWJaT1I+vv/BTG4K LOHdH8rktoJxQfosL/drOKzqznQYUE1wN/fR6vJK9GFNkZYvV2taimJ2iIrOl6hUHtrE onxwZFQVO8wcD+25VnfIVUgrvyg2KgbY3N1isLMNdB4pF9xyaX3b/pZcpG4CnWpzfXPP lTfeMjainZZId5MWV+8Jra0TSQg2iNTJGoDwKt6fEwgTcQcVhyAFsSb3H1oxXSOo6KPU y/PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bFPgt1tp; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q197-v6si3843544pgq.526.2018.09.27.23.48.02; Thu, 27 Sep 2018 23:48:02 -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=@linaro.org header.s=google header.b=bFPgt1tp; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728921AbeI1NKO (ORCPT + 32 others); Fri, 28 Sep 2018 09:10:14 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:32900 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbeI1NKN (ORCPT ); Fri, 28 Sep 2018 09:10:13 -0400 Received: by mail-pf1-f196.google.com with SMTP id d4-v6so3653262pfn.0 for ; Thu, 27 Sep 2018 23:47:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=p7VTwSew5JIQjBLJLLspuwEGyotzVxuUjhT6Cc4QWEY=; b=bFPgt1tplsXabUlQ6hCzj2urb7BtDmJeuUmQva+Qncik1zkUYv5VHI6lhF9oOye8/v Y+S8c0we9UP5r2SRWTJPjX3n6RRhyhpPNrtbFUtyk0LpbSHuAhLhWx3E0PCMQvFW8dky /BDwKAUo+vJkN8g49u451SCfEhAxV+z5uq9VI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p7VTwSew5JIQjBLJLLspuwEGyotzVxuUjhT6Cc4QWEY=; b=LMHpPceaxX/uE1dU7m1rYSvgKNgvGevQIlUPTpaZeeThMkdV2IPRswLsFc2oJKX9pX 6u3C76IrYlYHlGBChFIxYhzodCKScBJTR9UyFWKKkrGI82iu48lsK89tCd9ddsbK5LU5 FJtJhMUz3kEO817De2cUqowKxXdeYiQUxo8ZkAsFF6g44B5eQ/pIbI+ZbGRk8k/Vn3vd MVz5l7QlzjrzIT0BTwMus2GiPg3aGpE/s5ehgiG67yuqZQc4i47LiFPPMHK2GBMpscMe p2NEJ8E0w0/ogRgxfwBL4KGXmVpnMqHe93a2ZciINtzHEAPwTHW/foRYtqFqOFOM0Oqg e1+g== X-Gm-Message-State: ABuFfoif+7JbaKaeIc3aCJEaDh3QoK6ANc7mbZgQ1yUOfNFDZJ9ZlY73 Gjs6GoakuS+wNAHAjG0oi574YA== X-Received: by 2002:a62:3644:: with SMTP id d65-v6mr15022082pfa.133.1538117279596; Thu, 27 Sep 2018 23:47:59 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id f6-v6sm5312638pgf.52.2018.09.27.23.47.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 23:47:58 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, dhowells@redhat.com, vgoyal@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, dyoung@redhat.com, bhe@redhat.com, arnd@arndb.de, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com Cc: prudo@linux.ibm.com, ard.biesheuvel@linaro.org, james.morse@arm.com, bhsharma@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v15 01/16] asm-generic: add kexec_file_load system call to unistd.h Date: Fri, 28 Sep 2018 15:48:26 +0900 Message-Id: <20180928064841.14117-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180928064841.14117-1-takahiro.akashi@linaro.org> References: <20180928064841.14117-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The initial user of this system call number is arm64. Signed-off-by: AKASHI Takahiro Acked-by: Arnd Bergmann --- include/uapi/asm-generic/unistd.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.19.0 diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h index df4bedb9b01c..acea91e49523 100644 --- a/include/uapi/asm-generic/unistd.h +++ b/include/uapi/asm-generic/unistd.h @@ -736,9 +736,11 @@ __SYSCALL(__NR_statx, sys_statx) __SC_COMP(__NR_io_pgetevents, sys_io_pgetevents, compat_sys_io_pgetevents) #define __NR_rseq 293 __SYSCALL(__NR_rseq, sys_rseq) +#define __NR_kexec_file_load 294 +__SYSCALL(__NR_kexec_file_load, sys_kexec_file_load) #undef __NR_syscalls -#define __NR_syscalls 294 +#define __NR_syscalls 295 /* * 32 bit systems traditionally used different From patchwork Fri Sep 28 06:48:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 147768 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp370919lji; Thu, 27 Sep 2018 23:48:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV62FItWJjHC8dWtq6No4qCiwecLn2X+l+IBhE/VQojj8Gr2gwVlFIyuy1TV6BPNqVT5OJqho X-Received: by 2002:a63:7506:: with SMTP id q6-v6mr4248860pgc.137.1538117287855; Thu, 27 Sep 2018 23:48:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538117287; cv=none; d=google.com; s=arc-20160816; b=oCuzZugwfkoL9Aog1HHotEzIuOaeSW2lFZDzNpf5ofkim5dmISE5P13R3GMZ9HXn/g MSGia96L+Y6NxD8LhDKbxfzLm4fUCxsi/Eq9HQ9bB6Q6ga1biHHhhJrig1Sir40l9ooU QWfeSkmM5S5YweZT5SKuBDevGx9jINbUI2jPHeMu+TTIa6HpnJ7j5tUB2kAQZNp4nHU7 IszY8kCSKNeM1k6m6DovtElXQRoOEAeF2D486giv9iq5NAlpUaVM3aF6p+/ZHrGV2REf Gnijar51EPM192LC238t+OvrCklkuZMaTVorxKkLKN98PSVfZ+R0CgcIVxKbWKJZXjr/ V4oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SFnjB8OZwPCkN/cF+2XtrYPYnwjUqNvYjNJ7CAWxc5o=; b=k9mXLgM+899McJV6vTjooV7saJJuf24oOR25uqrjt3Fr5JC265o7g4p7bN7JHQN6sF tR690gyYi0ofzK/zM7waanByFwDWdSCdM2onBGEk+bmvpfcm9Tfe2V579TPEbzRlWmxD rbZy3ly9sI/pgPVc6oYQSB04duGlzipZ6ySbiRJcTHcUc6aG8ewj7LqCr7/wu78U8lgG Mi1W6sukoMTdExIRPI3rllTW44Xoe1uAXrKqk4QVlbNFfOHaL2/Tefa5R2I95BbkZPni E473QoLqi1kkpi1qACkqDV5Eyc6YwE+un7HTBfXno5PeXduvs1CmVRk+9/7r00mR0b8E SMGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NOu5gWVY; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q197-v6si3843544pgq.526.2018.09.27.23.48.07; Thu, 27 Sep 2018 23:48:07 -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=@linaro.org header.s=google header.b=NOu5gWVY; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728986AbeI1NKT (ORCPT + 32 others); Fri, 28 Sep 2018 09:10:19 -0400 Received: from mail-pg1-f173.google.com ([209.85.215.173]:42593 "EHLO mail-pg1-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbeI1NKT (ORCPT ); Fri, 28 Sep 2018 09:10:19 -0400 Received: by mail-pg1-f173.google.com with SMTP id i4-v6so3116249pgq.9 for ; Thu, 27 Sep 2018 23:48:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SFnjB8OZwPCkN/cF+2XtrYPYnwjUqNvYjNJ7CAWxc5o=; b=NOu5gWVY0xlMpxIclXnxjYR6bEPT29dU0ZklbtpXSY5Ypq8qCjjvQMi2SgJVNEJjEP YjEWlJKbjI/9XcoxOVGYN5Q1V5+A2MHBdjMa4vVEreAt9quWR2PwMrjes2N0vi6SeW66 3wKxN/9fSi1KQdhlDw7G7H7TV99dhfTxGOYoQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SFnjB8OZwPCkN/cF+2XtrYPYnwjUqNvYjNJ7CAWxc5o=; b=CTL/ijlo/RkZY0JqLWhgAAbLSK+IwWNCcES6+edTCpjS6eaVEyEWlLZBW/VHfN/z2o Kw0+H/O+w+R+8u3aS3g7MDvwdJ5t2KYtgtnSjUeulML4zX6ga8DtRf/zNk+DQ4XwuFKr 8jhkrEEr8QiXJooLgSCVYBKOIBvL305uP812maGviDPfc7lZI9HJ+xg9xFcgwxwDMq24 NcEi+txtJddS4UA0OjJ7SAlaUTqdSv28Cqr8LMsRl0oUjpdsLTL5d7M1mP3TwxjbZbP3 NH7dcwzSLRtJOWW7AEQo4uUzVMW2pCk/PgeUhlZWTn5lXeThNQu7PhtZwdcK2vfaoHWH BwmQ== X-Gm-Message-State: ABuFfojfu0Q4c+g7yFToYnsWBKoBrIUvtF1B208nKLvrSmPiQqaQT8IC NtcWHinmCLQ2QpMUSMDgK4Ngkw== X-Received: by 2002:aa7:8895:: with SMTP id l21-v6mr2833137pfo.74.1538117284863; Thu, 27 Sep 2018 23:48:04 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id a1-v6sm9770651pfc.28.2018.09.27.23.48.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 23:48:03 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, dhowells@redhat.com, vgoyal@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, dyoung@redhat.com, bhe@redhat.com, arnd@arndb.de, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com Cc: prudo@linux.ibm.com, ard.biesheuvel@linaro.org, james.morse@arm.com, bhsharma@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v15 02/16] kexec_file: make kexec_image_post_load_cleanup_default() global Date: Fri, 28 Sep 2018 15:48:27 +0900 Message-Id: <20180928064841.14117-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180928064841.14117-1-takahiro.akashi@linaro.org> References: <20180928064841.14117-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Change this function from static to global so that arm64 can implement its own arch_kimage_file_post_load_cleanup() later using kexec_image_post_load_cleanup_default(). Signed-off-by: AKASHI Takahiro Acked-by: Dave Young Cc: Vivek Goyal Cc: Baoquan He --- include/linux/kexec.h | 1 + kernel/kexec_file.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) -- 2.19.0 diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 9e4e638fb505..49ab758f4d91 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -143,6 +143,7 @@ extern const struct kexec_file_ops * const kexec_file_loaders[]; int kexec_image_probe_default(struct kimage *image, void *buf, unsigned long buf_len); +int kexec_image_post_load_cleanup_default(struct kimage *image); /** * struct kexec_buf - parameters for finding a place for a buffer in memory diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index c6a3b6851372..63c7ce1c0c3e 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -78,7 +78,7 @@ void * __weak arch_kexec_kernel_image_load(struct kimage *image) return kexec_image_load_default(image); } -static int kexec_image_post_load_cleanup_default(struct kimage *image) +int kexec_image_post_load_cleanup_default(struct kimage *image) { if (!image->fops || !image->fops->cleanup) return 0; From patchwork Fri Sep 28 06:48:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 147769 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp370990lji; Thu, 27 Sep 2018 23:48:13 -0700 (PDT) X-Google-Smtp-Source: ACcGV62V/Y3oeumCcDu35ig/H6mDksoVjrBa4ZzILLb2+mf7O0VkrRQ7pCyakgKSxGOfnxxQQJ5B X-Received: by 2002:a17:902:830a:: with SMTP id bd10-v6mr11276194plb.214.1538117293349; Thu, 27 Sep 2018 23:48:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538117293; cv=none; d=google.com; s=arc-20160816; b=XSz8Bv08hT36trCnEkcTMDJ6bKEK/Q3iFrH7aVjO7n0p41ZRZ/yDVZ9hP9BL5CJ/Q3 IylbDGWiEVJgf1DWhtevVfm4QhgBxBTedh4zTfboGoSNBGAlAFGQZYtKop5GJoFj/HI3 aAlDvlGrzHzLMOHzg1/YCfq/DBs7xXphDqu3C9KOFffA7z/BDinjP/IJaZXAMoJRdh91 gAEwcdFTxiJz37Agi/xbRzldxYAeqCwvnlBjoFTz9EId4zgLDv1urw5uxjCGkrxYUUHm Xyk80XfBcIWluAaTbBw5LwKiizuYC9JhwdKKJCjlxanEf+LiKx+nH5MMtgbD+i3gXx1M R7bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GkP10Cl5MP4nxVesufI8pOCjA8cWm/ywpOEKb9ueudc=; b=n+nGtw/5agiIwBjbiLlTl0c89s8uvHxt/rUDs1xtHl1gzrYRy7VYoZBUzmXsXaOaqR PctjEaSlXVwds0hGe7wY2HgA5Ceuw6WfYO9ngT7JuxU+ETpmzOCe2wIXK9/Ft83NmDnN merzAvkvp4k9ASjdFCVzINnjoUOTsMq1aoC7+MBFzjMVkm6FgfeNM/NYzemk/VZvld6Y ExQWxiZQrrHWAGIU8OsHMboZ8Lo2mZEBDWbiSCSAmsAHxUCCMqtw1cVGtf81eH3VOhPp JXssO6V2zIAx2iktHFY5iRMacib1mpkDaIgU67XwDtihzd1GHu7T7mvaKCrlbo5QhFS5 PknQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IkRQaACF; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e184-v6si4510234pfa.206.2018.09.27.23.48.13; Thu, 27 Sep 2018 23:48:13 -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=@linaro.org header.s=google header.b=IkRQaACF; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729015AbeI1NKZ (ORCPT + 32 others); Fri, 28 Sep 2018 09:10:25 -0400 Received: from mail-pg1-f181.google.com ([209.85.215.181]:36552 "EHLO mail-pg1-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbeI1NKY (ORCPT ); Fri, 28 Sep 2018 09:10:24 -0400 Received: by mail-pg1-f181.google.com with SMTP id f18-v6so222557pgv.3 for ; Thu, 27 Sep 2018 23:48:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GkP10Cl5MP4nxVesufI8pOCjA8cWm/ywpOEKb9ueudc=; b=IkRQaACFLS0lvXgRp3LiGqnUuHtzQt5Y9M7/3TW1yIkM8S+qtrisT+jwz/Z+t5Mtt6 EwAYVYbezOlY0HkVAPEh813zdFagQ85MAMNEph2blAqjyEocIINOAM1T8nVMc2kK+wSs lYdOPoCwYjU5W4wPToawZjAor310uRDhp2A/c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GkP10Cl5MP4nxVesufI8pOCjA8cWm/ywpOEKb9ueudc=; b=SfHHPyIT7EeRSfai41KXKyA6T5G0vf1sryjV+LLrVA/ENy8slDAv6dNgiwXkIU8PkW 1O8oTNf6KcN3ek8esbc0Sud/p4ApcAZTNv8WbvLHszaoM/nY2L3n3LYXcOL4KVDtQUV+ lffCbqadcNXAfO1hvycIW5mvEvdu8PqbVp9zQSjblSjiUY3Dy8b1fZNbjhV+CQLahaeI ATmFMfGQxN2ZnGICAdUIny55Ea0QxyOalD+EnaUa8QP4Bu49z+aqURTm6N/D2BO38gwm UO+2spYme+unNfbAQyA/nVQAWG0NzLnFAGrXWsBnhpxwPht6I438BiFfh1qaXQoifB/L p25Q== X-Gm-Message-State: ABuFfogXfFEIwSc8uvhN90rDDDz/j/48a5+eEdd8mTeGZMG6qJL7p76z 04tkrVBlfHfRwnsgAmDatcY5nw== X-Received: by 2002:a17:902:543:: with SMTP id 61-v6mr14871971plf.126.1538117289637; Thu, 27 Sep 2018 23:48:09 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id e68-v6sm7165147pfg.93.2018.09.27.23.48.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 23:48:08 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, dhowells@redhat.com, vgoyal@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, dyoung@redhat.com, bhe@redhat.com, arnd@arndb.de, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com Cc: prudo@linux.ibm.com, ard.biesheuvel@linaro.org, james.morse@arm.com, bhsharma@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v15 03/16] s390, kexec_file: drop arch_kexec_mem_walk() Date: Fri, 28 Sep 2018 15:48:28 +0900 Message-Id: <20180928064841.14117-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180928064841.14117-1-takahiro.akashi@linaro.org> References: <20180928064841.14117-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since s390 already knows where to locate buffers, calling arch_kexec_mem_walk() has no sense. So we can just drop it as kbuf->mem indicates this while all other architectures sets it to 0 initially. This change is a preparatory work for the next patch, where all the variant memory walks, either on system resource or memblock, will be put in one common place so that it will satisfy all the architectures' need. Signed-off-by: AKASHI Takahiro Reviewed-by: Philipp Rudo Cc: Martin Schwidefsky Cc: Heiko Carstens Cc: Dave Young Cc: Vivek Goyal Cc: Baoquan He --- arch/s390/kernel/machine_kexec_file.c | 10 ---------- include/linux/kexec.h | 8 ++++++++ kernel/kexec_file.c | 4 ++++ 3 files changed, 12 insertions(+), 10 deletions(-) -- 2.19.0 diff --git a/arch/s390/kernel/machine_kexec_file.c b/arch/s390/kernel/machine_kexec_file.c index f413f57f8d20..32023b4f9dc0 100644 --- a/arch/s390/kernel/machine_kexec_file.c +++ b/arch/s390/kernel/machine_kexec_file.c @@ -134,16 +134,6 @@ int kexec_file_add_initrd(struct kimage *image, struct s390_load_data *data, return ret; } -/* - * The kernel is loaded to a fixed location. Turn off kexec_locate_mem_hole - * and provide kbuf->mem by hand. - */ -int arch_kexec_walk_mem(struct kexec_buf *kbuf, - int (*func)(struct resource *, void *)) -{ - return 1; -} - int arch_kexec_apply_relocations_add(struct purgatory_info *pi, Elf_Shdr *section, const Elf_Shdr *relsec, diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 49ab758f4d91..f378cb786f1b 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -145,6 +145,14 @@ int kexec_image_probe_default(struct kimage *image, void *buf, unsigned long buf_len); int kexec_image_post_load_cleanup_default(struct kimage *image); +/* + * If kexec_buf.mem is set to this value, kexec_locate_mem_hole() + * will try to allocate free memory. Arch may overwrite it. + */ +#ifndef KEXEC_BUF_MEM_UNKNOWN +#define KEXEC_BUF_MEM_UNKNOWN 0 +#endif + /** * struct kexec_buf - parameters for finding a place for a buffer in memory * @image: kexec image in which memory to search. diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index 63c7ce1c0c3e..0fcaa86219d1 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -534,6 +534,10 @@ int kexec_locate_mem_hole(struct kexec_buf *kbuf) { int ret; + /* Arch knows where to place */ + if (kbuf->mem != KEXEC_BUF_MEM_UNKNOWN) + return 0; + ret = arch_kexec_walk_mem(kbuf, locate_mem_hole_callback); return ret == 1 ? 0 : -EADDRNOTAVAIL; From patchwork Fri Sep 28 06:48:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 147770 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp371036lji; Thu, 27 Sep 2018 23:48:16 -0700 (PDT) X-Google-Smtp-Source: ACcGV61ju3sm2Oad2P4RJ6rZoMxVjjHDZiNjVPAKU2VUXeq16hHrcHQkPcAjRNGT77d4gLSgderO X-Received: by 2002:a63:a362:: with SMTP id v34-v6mr13705663pgn.261.1538117296265; Thu, 27 Sep 2018 23:48:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538117296; cv=none; d=google.com; s=arc-20160816; b=MXtQe6KfHdqcdvvsJVBL5fMZD0MdjGA+mz8e99xU16kEKAK5LISyOrOe6SWwrdsdl3 NrSuINww2xcMZ2tAPontn8l3M1xt3pUcguptbT8QmXTAKHvdkLS0kb8PmZqGNuwx1W+a 5todA8u8v8QnGbaKEHserQJ3wcuT41Bm61rYvs+1mBkaGMxBpNtvRmuLNpECAE+g2jDc EzHr5DvOMLYKYhn2XOQnHZHa0jPfz9zNZG4sjRzq1eFcjiQQiuldjWlc8vy2HmKi00mv vuHsNBsdWbn29Y+ujwQGGDJqi3643bPM7sXxXH5d+HfGrV5RnaULzQNx+Quo2sH6dlHx m2iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QZGnKdcuU+QxzJqLLsvEp1lZ/3WCKPgonwBfWd5z9t4=; b=mfhB22p5Sib6hMseUVVPXP8U4U+duggxrxU8UlypPeunfeW4Mxtyux4BYbKecid086 NDDi6HfPgIlB9cM5TgMr+J67wu2GPLODQzITjI+4cdlTwhtOFRGdRLjci/NqkjyMIoWL aqyPyCU3WLAWDDJahObfELbfPJedJkh13wCBcJzqN+/JqUQ1K4Ib9/zt9ti2H1+0Wznm zh51t81XucUVIdYrSkHXfz1fwk79eSRTcatWS0vSE9m/khG68pBsVzvu9grBy9jLGZaX jvwWVftd8rt1RqiuQHJy4HPezKjXZzSO3F33z1C9zcyNIV1su1mZBf/nF4O6rvO4VBJi Nxtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GMRI5rLS; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e184-v6si4510234pfa.206.2018.09.27.23.48.16; Thu, 27 Sep 2018 23:48:16 -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=@linaro.org header.s=google header.b=GMRI5rLS; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729044AbeI1NK2 (ORCPT + 32 others); Fri, 28 Sep 2018 09:10:28 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:45715 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbeI1NK2 (ORCPT ); Fri, 28 Sep 2018 09:10:28 -0400 Received: by mail-pg1-f196.google.com with SMTP id t70-v6so3705488pgd.12 for ; Thu, 27 Sep 2018 23:48:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QZGnKdcuU+QxzJqLLsvEp1lZ/3WCKPgonwBfWd5z9t4=; b=GMRI5rLStlj7z2WUaq7i+r7ic6z6h9eBlRzw1ReZKo6ppfjuzhpOVMpKl9vprH6VwN 5YcbxBbgpvKbosfXHGoKfpemYdL0BN7elOum100H/l032dciAePfu9SaOGOm3ge+QBUD hOMbaE4k29aNaEyiAz7RgfdHQndFToGVjTWg0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QZGnKdcuU+QxzJqLLsvEp1lZ/3WCKPgonwBfWd5z9t4=; b=nIEhMXOcvboKWLJlkTHPMiLvsWjTJXWsUdjqAISgEz+/VY8uemoK1UmEpa39LUZW2P ul/VyXlDduHynHGe+HiDuZOFye5LQFSeV30IhtCEPqTRlvkVm64EDu7lVpG8D2d8X1wz sKEPxKQSVpgalyq7nLpbtIoh8pXq44z82jbZnA5R96U6kFkIRbe5ejTuAdqzqWS6Yhks KlYgEMhdeDihyZWQ5NbSRyf0PdjZhU+8QC0xi0+yqtrJ6IT0kbQerAWVEo9vbJyEFa/6 Ru0/eO5YvQwUWFsR/nOgRDO7EWsBzDCNcBrgDLGwga8qcMdFgXldpxbu2eu004dcohBV 7tBQ== X-Gm-Message-State: ABuFfojnWTnUJIaL2dJvyxDqPxgfHaaTd0tbl9AgHXba0/KRB073h++0 MUifSeeCWsBIkcfxoghhIjiDCg== X-Received: by 2002:a17:902:5a0f:: with SMTP id q15-v6mr14788388pli.253.1538117293618; Thu, 27 Sep 2018 23:48:13 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id d7-v6sm1761775pfm.23.2018.09.27.23.48.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 23:48:12 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, dhowells@redhat.com, vgoyal@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, dyoung@redhat.com, bhe@redhat.com, arnd@arndb.de, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com Cc: prudo@linux.ibm.com, ard.biesheuvel@linaro.org, james.morse@arm.com, bhsharma@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro , "Eric W. Biederman" Subject: [PATCH v15 04/16] powerpc, kexec_file: factor out memblock-based arch_kexec_walk_mem() Date: Fri, 28 Sep 2018 15:48:29 +0900 Message-Id: <20180928064841.14117-5-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180928064841.14117-1-takahiro.akashi@linaro.org> References: <20180928064841.14117-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Memblock list is another source for usable system memory layout. So move powerpc's arch_kexec_walk_mem() to common code so that other memblock-based architectures, particularly arm64, can also utilise it. A moved function is now renamed to kexec_walk_memblock() and integrated into kexec_locate_mem_hole(), which will now be usable for all architectures with no need for overriding arch_kexec_walk_mem(). With this change, arch_kexec_walk_mem() need no longer be a weak function, and was now renamed to kexec_walk_resources(). Since powerpc doesn't support kdump in its kexec_file_load(), the current kexec_walk_memblock() won't work for kdump either in this form, this will be fixed in the next patch. Signed-off-by: AKASHI Takahiro Cc: "Eric W. Biederman" Acked-by: Dave Young Cc: Vivek Goyal Cc: Baoquan He Acked-by: James Morse --- arch/powerpc/kernel/machine_kexec_file_64.c | 54 ------------------- include/linux/kexec.h | 2 - kernel/kexec_file.c | 60 +++++++++++++++++++-- 3 files changed, 57 insertions(+), 59 deletions(-) -- 2.19.0 diff --git a/arch/powerpc/kernel/machine_kexec_file_64.c b/arch/powerpc/kernel/machine_kexec_file_64.c index c77e95e9b384..0d20c7ad40fa 100644 --- a/arch/powerpc/kernel/machine_kexec_file_64.c +++ b/arch/powerpc/kernel/machine_kexec_file_64.c @@ -24,7 +24,6 @@ #include #include -#include #include #include #include @@ -46,59 +45,6 @@ int arch_kexec_kernel_image_probe(struct kimage *image, void *buf, return kexec_image_probe_default(image, buf, buf_len); } -/** - * arch_kexec_walk_mem - call func(data) for each unreserved memory block - * @kbuf: Context info for the search. Also passed to @func. - * @func: Function to call for each memory block. - * - * This function is used by kexec_add_buffer and kexec_locate_mem_hole - * to find unreserved memory to load kexec segments into. - * - * Return: The memory walk will stop when func returns a non-zero value - * and that value will be returned. If all free regions are visited without - * func returning non-zero, then zero will be returned. - */ -int arch_kexec_walk_mem(struct kexec_buf *kbuf, - int (*func)(struct resource *, void *)) -{ - int ret = 0; - u64 i; - phys_addr_t mstart, mend; - struct resource res = { }; - - if (kbuf->top_down) { - for_each_free_mem_range_reverse(i, NUMA_NO_NODE, 0, - &mstart, &mend, NULL) { - /* - * In memblock, end points to the first byte after the - * range while in kexec, end points to the last byte - * in the range. - */ - res.start = mstart; - res.end = mend - 1; - ret = func(&res, kbuf); - if (ret) - break; - } - } else { - for_each_free_mem_range(i, NUMA_NO_NODE, 0, &mstart, &mend, - NULL) { - /* - * In memblock, end points to the first byte after the - * range while in kexec, end points to the last byte - * in the range. - */ - res.start = mstart; - res.end = mend - 1; - ret = func(&res, kbuf); - if (ret) - break; - } - } - - return ret; -} - /** * setup_purgatory - initialize the purgatory's global variables * @image: kexec image. diff --git a/include/linux/kexec.h b/include/linux/kexec.h index f378cb786f1b..d58d1f2fab10 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -192,8 +192,6 @@ int __weak arch_kexec_apply_relocations(struct purgatory_info *pi, const Elf_Shdr *relsec, const Elf_Shdr *symtab); -int __weak arch_kexec_walk_mem(struct kexec_buf *kbuf, - int (*func)(struct resource *, void *)); extern int kexec_add_buffer(struct kexec_buf *kbuf); int kexec_locate_mem_hole(struct kexec_buf *kbuf); diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index 0fcaa86219d1..370d7eab49fe 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -501,6 +502,55 @@ static int locate_mem_hole_callback(struct resource *res, void *arg) return locate_mem_hole_bottom_up(start, end, kbuf); } +#if defined(CONFIG_HAVE_MEMBLOCK) && !defined(CONFIG_ARCH_DISCARD_MEMBLOCK) +static int kexec_walk_memblock(struct kexec_buf *kbuf, + int (*func)(struct resource *, void *)) +{ + int ret = 0; + u64 i; + phys_addr_t mstart, mend; + struct resource res = { }; + + if (kbuf->top_down) { + for_each_free_mem_range_reverse(i, NUMA_NO_NODE, 0, + &mstart, &mend, NULL) { + /* + * In memblock, end points to the first byte after the + * range while in kexec, end points to the last byte + * in the range. + */ + res.start = mstart; + res.end = mend - 1; + ret = func(&res, kbuf); + if (ret) + break; + } + } else { + for_each_free_mem_range(i, NUMA_NO_NODE, 0, &mstart, &mend, + NULL) { + /* + * In memblock, end points to the first byte after the + * range while in kexec, end points to the last byte + * in the range. + */ + res.start = mstart; + res.end = mend - 1; + ret = func(&res, kbuf); + if (ret) + break; + } + } + + return ret; +} +#else +static int kexec_walk_memblock(struct kexec_buf *kbuf, + int (*func)(struct resource *, void *)) +{ + return 0; +} +#endif + /** * arch_kexec_walk_mem - call func(data) on free memory regions * @kbuf: Context info for the search. Also passed to @func. @@ -510,8 +560,8 @@ static int locate_mem_hole_callback(struct resource *res, void *arg) * and that value will be returned. If all free regions are visited without * func returning non-zero, then zero will be returned. */ -int __weak arch_kexec_walk_mem(struct kexec_buf *kbuf, - int (*func)(struct resource *, void *)) +static int kexec_walk_resources(struct kexec_buf *kbuf, + int (*func)(struct resource *, void *)) { if (kbuf->image->type == KEXEC_TYPE_CRASH) return walk_iomem_res_desc(crashk_res.desc, @@ -538,7 +588,11 @@ int kexec_locate_mem_hole(struct kexec_buf *kbuf) if (kbuf->mem != KEXEC_BUF_MEM_UNKNOWN) return 0; - ret = arch_kexec_walk_mem(kbuf, locate_mem_hole_callback); + if (IS_ENABLED(CONFIG_HAVE_MEMBLOCK) && + !IS_ENABLED(CONFIG_ARCH_DISCARD_MEMBLOCK)) + ret = kexec_walk_memblock(kbuf, locate_mem_hole_callback); + else + ret = kexec_walk_resources(kbuf, locate_mem_hole_callback); return ret == 1 ? 0 : -EADDRNOTAVAIL; } From patchwork Fri Sep 28 06:48:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 147771 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp371109lji; Thu, 27 Sep 2018 23:48:22 -0700 (PDT) X-Google-Smtp-Source: ACcGV62kPbTv7elPsI3rQCd6Bo/BFczqQKBzYS7/pqTRuBLx/7C3/kDutOeKEfIeNCN57NrmkbFm X-Received: by 2002:a63:906:: with SMTP id 6-v6mr13316828pgj.92.1538117301978; Thu, 27 Sep 2018 23:48:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538117301; cv=none; d=google.com; s=arc-20160816; b=FNeieM6fvrOL+TC/QTb7JC/vA7PQYecdrt0waaJeulzRfNy1QPa3JKhpqMEfofoh8M nPaYvJRe4Iu98C+rdzSZjfku+cMaKhEzAjMRNhXrLxzGfu3MLu1VZ7ocQFugQq+QdJGc tUSozlnoSROo4yh66Iwn49UWgg18R2StgrGMf6qU93CvH0p7zMvoazhF7Q01M2m4kD+r 8h8snlnx1EPzzAKBKmvBWJs3HFb8x5xYT1yhA/zhkIP00j79isBhJF8kQdS+WSeGH1rq 4wpQ7+CPUK/ntccv+C7B9R1nVp3w32h6jgq+z/KaZbP89B4zY+6twobANdevwhPN7CH0 H50g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7lEK32bpyfZBbvzr+AgaMH3E2lcp0Tdtbfmv5MlM7pE=; b=NDsXTr8lVScBUHVeyH8t2bWAkH6b9TajvfSLHPYmGSaqX6jgITn/9KokdMnqM78vX3 nsfMOmUAojozUGwq8eExTRvsBWDmTNpJK5Uz5JSROsgSiLJVWPozR+BzPBvDMwJK1a4b REeG9Z0y4LC0M+D7CYhvkvlNy3s3LxgjAff2bbWE0Orn3eAOkese6IFyWuhJDR6ECF8T NTUGSW0lNHkTG+yN295P34ztHn45pegDkBoRdgT2n2uG+EHLqmqC3q0vo6pDZGNvK0PY c97buZe6+Mp9zdemDnsTsI9tVyiX7NvzxSP6cjWOeU6DnBEQb3yASaVMeVlqg22r1Q7r 0fBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kk2MuAr2; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 62-v6si4223799plc.96.2018.09.27.23.48.21; Thu, 27 Sep 2018 23:48:21 -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=@linaro.org header.s=google header.b=Kk2MuAr2; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729062AbeI1NKd (ORCPT + 32 others); Fri, 28 Sep 2018 09:10:33 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:40587 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbeI1NKd (ORCPT ); Fri, 28 Sep 2018 09:10:33 -0400 Received: by mail-pf1-f193.google.com with SMTP id s5-v6so3624633pfj.7 for ; Thu, 27 Sep 2018 23:48:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7lEK32bpyfZBbvzr+AgaMH3E2lcp0Tdtbfmv5MlM7pE=; b=Kk2MuAr2ZxQGAFTckoI4a3OJjqCm/d1ykOA9ozVI2d5mQlhjrcGdC9cRGkw13D3b5+ luxQvhuNtGsEi3sx4uVzGEz+tkO982AHPYPk2EFmfsZAQmC6Xwqt/4DxGwu7a7IsX9bz fTR41f4878GBeepJZeruzkxW8PtyUjdFaHlW8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7lEK32bpyfZBbvzr+AgaMH3E2lcp0Tdtbfmv5MlM7pE=; b=NXNRtCdhb01Qoq3ARJ+SdiLA82plJNefxGSqM/OaMronory5oteHmG0NDhd7h8CMbV gMhd67vg0UcpdrlkSbU7R1pMTj66E1f2HyZsU2RyR9er3FQHo1pwAjIjPZ1Yx6P0WbJo pL+sflvCx+62Z39CjKggfYfostFmFyEmJbzLrODiCRfsgamJSPsDJe6yHgrQL8THrIdR 22AZGgNrIrH0TbYdplKMWVAotR5QN2BE11okO0RmX3EL84XyU8EvKh4zsI9Lpkxtmq07 dy8N3SbQ9b2v9XLtSJa4YR9uzHuylfyDi/8rydND57XCKgMmpV8DjgjKbEWJTanv9ouf eirQ== X-Gm-Message-State: ABuFfogL7iQ5O35FADO77IvdsF+w0qcuQoOK4mKTbNSDMtzfSoFg1efn KmvRWU9SR/pzsVgGnXjJSuUhng== X-Received: by 2002:a17:902:9045:: with SMTP id w5-v6mr14943273plz.10.1538117298309; Thu, 27 Sep 2018 23:48:18 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id h12-v6sm5847448pfo.135.2018.09.27.23.48.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 23:48:17 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, dhowells@redhat.com, vgoyal@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, dyoung@redhat.com, bhe@redhat.com, arnd@arndb.de, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com Cc: prudo@linux.ibm.com, ard.biesheuvel@linaro.org, james.morse@arm.com, bhsharma@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v15 05/16] kexec_file: kexec_walk_memblock() only walks a dedicated region at kdump Date: Fri, 28 Sep 2018 15:48:30 +0900 Message-Id: <20180928064841.14117-6-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180928064841.14117-1-takahiro.akashi@linaro.org> References: <20180928064841.14117-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In kdump case, there exists only one dedicated memblock region as usable memory (crashk_res). With this patch, kexec_walk_memblock() runs a given callback function on this region. Cosmetic change: 0 to MEMBLOCK_NONE at for_each_free_mem_range*() Signed-off-by: AKASHI Takahiro Cc: Dave Young Cc: Vivek Goyal Cc: Baoquan He --- kernel/kexec_file.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 2.19.0 Acked-by: Dave Young diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index 370d7eab49fe..2f615a7968dd 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -511,8 +511,11 @@ static int kexec_walk_memblock(struct kexec_buf *kbuf, phys_addr_t mstart, mend; struct resource res = { }; + if (kbuf->image->type == KEXEC_TYPE_CRASH) + return func(&crashk_res, kbuf); + if (kbuf->top_down) { - for_each_free_mem_range_reverse(i, NUMA_NO_NODE, 0, + for_each_free_mem_range_reverse(i, NUMA_NO_NODE, MEMBLOCK_NONE, &mstart, &mend, NULL) { /* * In memblock, end points to the first byte after the @@ -526,8 +529,8 @@ static int kexec_walk_memblock(struct kexec_buf *kbuf, break; } } else { - for_each_free_mem_range(i, NUMA_NO_NODE, 0, &mstart, &mend, - NULL) { + for_each_free_mem_range(i, NUMA_NO_NODE, MEMBLOCK_NONE, + &mstart, &mend, NULL) { /* * In memblock, end points to the first byte after the * range while in kexec, end points to the last byte From patchwork Fri Sep 28 06:48:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 147773 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp371225lji; Thu, 27 Sep 2018 23:48:31 -0700 (PDT) X-Google-Smtp-Source: ACcGV61x4SmLVEXu7MOXt/nt5BuoRY3muQJchjwELccyMmqSTv/YP4K/pvpL6/ivyXGM6Mkc2L2+ X-Received: by 2002:a17:902:585:: with SMTP id f5-v6mr14786573plf.7.1538117311332; Thu, 27 Sep 2018 23:48:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538117311; cv=none; d=google.com; s=arc-20160816; b=wRyhbosemTqTCzL5RntnB/0hc3sfaXU1g7Ok5UAliQaDvVa5ufxHp2Fz1LZVTM1KH3 S69U3kl9Vu9U5VoY2jdP/Jikza8uMOGC5YJMNpC0W6ejRCwV62glacp2mcZTJ9tz7WzR kIRrNAmFnN7Olj3J1H8CrAbs+i6ke8Cp2DZ5z2p9l5ZT8gglkg6LIrp5c+1rkY0gzA3E zn8jT6O0USs1f+9ILnjFUXcta6g7vXiZn0F3/Eru8fPSlBBmMWMFXIXoreObHkuzzCFl MYhyWq4tf9aAb+yMG/0LwUJ5jcIpd4EQ86Jlxo8FoS1voOJ/MaEHVB3j3LyOgRdpVAJ+ eIvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PN5LeK8svtoziSd5ZB0HR3YbxUdhrZV+lLkgGkSy5ww=; b=ethTGBJg4oYkPlsrP8uskHfdYIT5yBKIcmtrOZyZiAMLe1AGVygvlAdvRAHfPXtmSH PrxNDmF+xU/5rz16dmY7AvdzMBnPqhzNmqyPWChtXiBN9h5UDvMDY7NGrJm5K1h5akAD Gr8sgqbpcyhjbewe9f772qZVntAIScWObZMWJL80Fs3GXX6rfzZ9Al9L89zFXNiT/lFX PGAJmiCBmUwu/CcuNf42uGNT5IysxRzhCeQiUdO8fNGxVftFgfMWbWE0IwrDMtoEybHN UrgOX0L9fe9CUioeHbqbQwzMcQQAo95GMkgOx22EAtxEFHZV9lDjQKwX60A8fooOKZ/A jyBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Sr+o5pxe; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p12-v6si4165819pfj.244.2018.09.27.23.48.31; Thu, 27 Sep 2018 23:48:31 -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=@linaro.org header.s=google header.b=Sr+o5pxe; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729097AbeI1NKm (ORCPT + 32 others); Fri, 28 Sep 2018 09:10:42 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:32980 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbeI1NKm (ORCPT ); Fri, 28 Sep 2018 09:10:42 -0400 Received: by mail-pg1-f193.google.com with SMTP id y18-v6so3749854pge.0 for ; Thu, 27 Sep 2018 23:48:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PN5LeK8svtoziSd5ZB0HR3YbxUdhrZV+lLkgGkSy5ww=; b=Sr+o5pxeVXKOqw06DTNMIn4lVoKNr0kR4J9mRDFNopsLcBVTUokarh6DZcfsqDq0QC OFUT3k1jL133SZm3xC4fX3bXuVzu2TXeJOiVSRDTXzLuLjuV+vhNHNBPSMoCQPUanvUr P7wYBet1ILkC9dYZAI7aZV24GEykbffCAJv4w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PN5LeK8svtoziSd5ZB0HR3YbxUdhrZV+lLkgGkSy5ww=; b=BLjC/Hyui3REFugWfju7yziW7VS8319uvRgUPdZNVUa35k1o0jThRMnZKgxvwTc93W qqNkhEsTlerNElNNu5BTMxsil/X0OW2VF3UDscf+hVpJUCcfV9HANiYOCcE6vDT8g7Yd 0JkTlYTNhNfjp3bux8dk7wtjkX2FkF2TBVEaAphtJnMzqVDAjgv+QOYOgGRFHTUsXqmp dTJgmfwoBAQNz1Jl5MkI0ADr959G4aypgPndQKgOtZZkTgGH7ntfrccLKNM47JHVwEff RA51V38By/zi+n81/jeq6NvDZdcGPQyxbZpZEgvyn1dJWeXiKRPWySn7pErap2jqTlAo ouTA== X-Gm-Message-State: ABuFfojQ1Z8VS77OyNpQbCTN62Of6oMCwo06xps6ll/j9nhT0XLnjPGk rDlVDWkOjts4V9I9vlJpKjxoVQ== X-Received: by 2002:a17:902:c01:: with SMTP id 1-v6mr14301101pls.122.1538117307811; Thu, 27 Sep 2018 23:48:27 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id 3-v6sm6995090pfq.10.2018.09.27.23.48.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 23:48:26 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, dhowells@redhat.com, vgoyal@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, dyoung@redhat.com, bhe@redhat.com, arnd@arndb.de, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com Cc: prudo@linux.ibm.com, ard.biesheuvel@linaro.org, james.morse@arm.com, bhsharma@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v15 07/16] arm64: add image head flag definitions Date: Fri, 28 Sep 2018 15:48:32 +0900 Message-Id: <20180928064841.14117-8-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180928064841.14117-1-takahiro.akashi@linaro.org> References: <20180928064841.14117-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Those image head's flags will be used later by kexec_file loader. Signed-off-by: AKASHI Takahiro Cc: Catalin Marinas Cc: Will Deacon Acked-by: James Morse --- arch/arm64/include/asm/boot.h | 15 +++++++++++++++ arch/arm64/kernel/head.S | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) -- 2.19.0 diff --git a/arch/arm64/include/asm/boot.h b/arch/arm64/include/asm/boot.h index 355e552a9175..0bab7eed3012 100644 --- a/arch/arm64/include/asm/boot.h +++ b/arch/arm64/include/asm/boot.h @@ -5,6 +5,21 @@ #include +#define ARM64_MAGIC "ARM\x64" + +#define HEAD_FLAG_BE_SHIFT 0 +#define HEAD_FLAG_PAGE_SIZE_SHIFT 1 +#define HEAD_FLAG_BE_MASK 0x1 +#define HEAD_FLAG_PAGE_SIZE_MASK 0x3 + +#define HEAD_FLAG_BE 1 +#define HEAD_FLAG_PAGE_SIZE_4K 1 +#define HEAD_FLAG_PAGE_SIZE_16K 2 +#define HEAD_FLAG_PAGE_SIZE_64K 3 + +#define head_flag_field(flags, field) \ + (((flags) >> field##_SHIFT) & field##_MASK) + /* * arm64 requires the DTB to be 8 byte aligned and * not exceed 2MB in size. diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index b0853069702f..8cbac6232ed1 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -91,7 +91,7 @@ _head: .quad 0 // reserved .quad 0 // reserved .quad 0 // reserved - .ascii "ARM\x64" // Magic number + .ascii ARM64_MAGIC // Magic number #ifdef CONFIG_EFI .long pe_header - _head // Offset to the PE header. From patchwork Fri Sep 28 06:48:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 147774 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp371272lji; Thu, 27 Sep 2018 23:48:35 -0700 (PDT) X-Google-Smtp-Source: ACcGV63cKoOMbZkIl7Q2TNChgazDWvGEJdKlHecGP1kPJ7PPaVgJjbEPOMq6Zc217NfVA6Dqw24p X-Received: by 2002:a17:902:43e4:: with SMTP id j91-v6mr2219905pld.74.1538117315697; Thu, 27 Sep 2018 23:48:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538117315; cv=none; d=google.com; s=arc-20160816; b=XfOWVkHEjYFNLCNG9deFkJngiD8amS/Oe9IzVGjbhPuL7hTX19jWXHAvvNoCrCy9q/ +3cI3WWWoPsqadY63f1k1REor6IPATA4A2qawHabygHSv90TH1NgezqmQlEE60IzegWN YrF0eeYrG98fzqMW2mMGASYKZ+HzVZnbRFOH2Ebyj+kQkG9HR3uz7JWyas11mscl9HQc zAtJ8XPupiSV7Ja1YOlGJe5OaJgjez35LUaTAZx/PBvwwsff9j+OzEeO8ZFozE0SsrNj 2AQoSz6vilwVW6g8Ibrq7MHmKg3iC6QcU3EZaY68OjyaXIdzFYvJnhG3253fqPIYsny9 JtXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4VJX5OtbVz8vzfF/CMl4UANq631qfAiD/HWUtm1wpWw=; b=KaFK17blE01owUNKG3HA0yFQB3P0hRQ1T1IzudbKAFQenKqczMlMK3OD7FUyEaiITJ hyKFhFP4vTR8wAeav1pKVNPmK1B8OqYdop6cSMFYf7Jx43JSPM8Ta4wdCeAwndEzBcRv 1Njtd6samWsZ+EFfiNLHsBI/WqTbQyNozeZjN17i0aUEMlrf8OspOtScLG7NvW7lpIgU gf7CP/g01WdaGD/K5alqxNjOq9rGnZjOZIgP9cT/7R3l7EYkm+kZ8hveVKdhY7G0gNQW nzB1fQFrqwO9J5MrPl1erlmEthiVyHqIwdkL8zID0XTngnnUOnV3GrzlvROTc8269No3 T5XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MaprZxME; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p12-v6si4165819pfj.244.2018.09.27.23.48.35; Thu, 27 Sep 2018 23:48:35 -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=@linaro.org header.s=google header.b=MaprZxME; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729119AbeI1NKs (ORCPT + 32 others); Fri, 28 Sep 2018 09:10:48 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:43319 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbeI1NKr (ORCPT ); Fri, 28 Sep 2018 09:10:47 -0400 Received: by mail-pg1-f196.google.com with SMTP id q19-v6so3715649pgn.10 for ; Thu, 27 Sep 2018 23:48:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4VJX5OtbVz8vzfF/CMl4UANq631qfAiD/HWUtm1wpWw=; b=MaprZxMEOptN6Y1PB4m8DaHjLUv1xwZglze7vHiCUBjtXFko9ADVOqvNtzuND72J6M yyckY2B3mKQKPzbxBQVTmVIbaPPw678THitZlBL9FdvrHCAq7Fm7knKejpDVshXvDsOC 9zlI5QDH9W7qxx4BpPrbX1kMrApuilWGjHMhk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4VJX5OtbVz8vzfF/CMl4UANq631qfAiD/HWUtm1wpWw=; b=kIv3KZ82KRG41jVBXxVMo3NVl3OnT2D9aj5uVOOx++3typGbP4g4n3OhWviS5gN+YY oDnhA8LBZkLdRUhktNKl5OVEWVq9Ya35g4PjTV3XDpPqEbBbAGzi+w6iIJYB7LtzfdqV hDe3VhEq4d3WmkhBGy+uJ0TfMd8ptbaLAa1I/mW3Pn0rTYUvbRDtWWf85Q0SAhwXveTb co3OyiLHmmLM9C/K0g6IBzBZMq1lLpEnzz9dX3T/t45Qsc5Z821oc7dldxfZ6NcvEdtX omkW3PdxJPOMZPxmujnEZOzNvFQ+oHtBFuS+hb2yO1xYeKvxBMqdJFpmb5HFAOvKUFV1 DRlQ== X-Gm-Message-State: ABuFfoi+JSgAAM2nJWVG2Vz6hAnIxuF/KJ4pUtV8Fkz/lAaFat0qKUTF g8EaNUmuPv5CvkEyaBXpIBQv8w== X-Received: by 2002:a62:384c:: with SMTP id f73-v6mr15351621pfa.242.1538117312657; Thu, 27 Sep 2018 23:48:32 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id c85-v6sm5903582pfb.147.2018.09.27.23.48.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 23:48:31 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, dhowells@redhat.com, vgoyal@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, dyoung@redhat.com, bhe@redhat.com, arnd@arndb.de, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com Cc: prudo@linux.ibm.com, ard.biesheuvel@linaro.org, james.morse@arm.com, bhsharma@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v15 08/16] arm64: cpufeature: add MMFR0 helper functions Date: Fri, 28 Sep 2018 15:48:33 +0900 Message-Id: <20180928064841.14117-9-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180928064841.14117-1-takahiro.akashi@linaro.org> References: <20180928064841.14117-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Those helper functions for MMFR0 register will be used later by kexec_file loader. Signed-off-by: AKASHI Takahiro Cc: Catalin Marinas Cc: Will Deacon Reviewed-by: James Morse --- arch/arm64/include/asm/cpufeature.h | 48 +++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) -- 2.19.0 diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index 1717ba1db35d..cd90b5252d6d 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -486,11 +486,59 @@ static inline bool system_supports_32bit_el0(void) return cpus_have_const_cap(ARM64_HAS_32BIT_EL0); } +static inline bool system_supports_4kb_granule(void) +{ + u64 mmfr0; + u32 val; + + mmfr0 = read_sanitised_ftr_reg(SYS_ID_AA64MMFR0_EL1); + val = cpuid_feature_extract_unsigned_field(mmfr0, + ID_AA64MMFR0_TGRAN4_SHIFT); + + return val == ID_AA64MMFR0_TGRAN4_SUPPORTED; +} + +static inline bool system_supports_64kb_granule(void) +{ + u64 mmfr0; + u32 val; + + mmfr0 = read_sanitised_ftr_reg(SYS_ID_AA64MMFR0_EL1); + val = cpuid_feature_extract_unsigned_field(mmfr0, + ID_AA64MMFR0_TGRAN64_SHIFT); + + return val == ID_AA64MMFR0_TGRAN64_SUPPORTED; +} + +static inline bool system_supports_16kb_granule(void) +{ + u64 mmfr0; + u32 val; + + mmfr0 = read_sanitised_ftr_reg(SYS_ID_AA64MMFR0_EL1); + val = cpuid_feature_extract_unsigned_field(mmfr0, + ID_AA64MMFR0_TGRAN16_SHIFT); + + return val == ID_AA64MMFR0_TGRAN16_SUPPORTED; +} + static inline bool system_supports_mixed_endian_el0(void) { return id_aa64mmfr0_mixed_endian_el0(read_sanitised_ftr_reg(SYS_ID_AA64MMFR0_EL1)); } +static inline bool system_supports_mixed_endian(void) +{ + u64 mmfr0; + u32 val; + + mmfr0 = read_sanitised_ftr_reg(SYS_ID_AA64MMFR0_EL1); + val = cpuid_feature_extract_unsigned_field(mmfr0, + ID_AA64MMFR0_BIGENDEL_SHIFT); + + return val == 0x1; +} + static inline bool system_supports_fpsimd(void) { return !cpus_have_const_cap(ARM64_HAS_NO_FPSIMD); From patchwork Fri Sep 28 06:48:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 147775 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp371388lji; Thu, 27 Sep 2018 23:48:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV63h/wiFGqFqWd6y2MtDmIYv7J6UwMKaYLDQyYreigQW71GSM9MpKm2o70IUK67cQY8aAFHw X-Received: by 2002:a62:13cb:: with SMTP id 72-v6mr10325711pft.34.1538117324556; Thu, 27 Sep 2018 23:48:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538117324; cv=none; d=google.com; s=arc-20160816; b=0hpoQy3H3yNpeVJJHygiXOkpY1Ok908UCz/kEke0sZvbPMMT4KxHGBxVLNPqVCRwpY z97cWMEgPgImlPVuJWuPc9yil4mUSIGLaDc+ELO+UA/jkvZkmsrvkTLXfb7uGuQ8ztXM /zNmEgfPQZ+FtbXIt9FwrMHT4nGkj/plsWWjz7OqvIopXX8p9YsSHOX/SUzLYMXG75Mu +CdDK5FLrUsJzPQ4Vos7MzvXuLn9py7YJYZafa8oHKev9yigwdxmS/NVJWvEOXgU+Lm3 ni/MTuAJXiCfeAOQB71vLXVuDQy23L/zhbRrCwiib2wC3M9ZRyoecud8GjUO7t4egr5B ldAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=N8QYerXEaqWdfHlNx6gpLi8IwzqsBwOqOFk9N60B1+Q=; b=NHeLyHWavouOQJjXHN87uBBPupRt5Zx8hez176b1S3eHOB4Dtw8IwCKOjK4+kaGzSy GQUdKSwU3+LJVPusDRRqbkpgcZJzfwNcbEUI5se1ZiyUpcVAgQ74E5Zx4E+/0tVv9pB3 EPcOmYXt8/jZ6ktrRJnWcZnlcMlgiBU55hTQaYarVxjy1+e2J4yonzAc/Ca2cNkEZxtq 5OO1m7M9YQhNOQNwn4z5BJ0vxrwTv43AWTED72KRiZdonKArr2DlQM+9iiud6CRu+5H9 oCviMw+yRv1KiJFPWDKNh7pUSK5K5rhL5azjw5OzS7ccU0Lb4TuL02edRAbcBp/ct4YL 05Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Tc7XQ2hZ; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d7-v6si3987407plo.418.2018.09.27.23.48.44; Thu, 27 Sep 2018 23:48:44 -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=@linaro.org header.s=google header.b=Tc7XQ2hZ; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729136AbeI1NK4 (ORCPT + 32 others); Fri, 28 Sep 2018 09:10:56 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:34580 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbeI1NKz (ORCPT ); Fri, 28 Sep 2018 09:10:55 -0400 Received: by mail-pf1-f196.google.com with SMTP id k19-v6so3645416pfi.1 for ; Thu, 27 Sep 2018 23:48:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=N8QYerXEaqWdfHlNx6gpLi8IwzqsBwOqOFk9N60B1+Q=; b=Tc7XQ2hZJ6SjS4SXXcKYB/SZbNb8G/jmNJ+1vuqJYd6C/k6BbqE+edQSjeMnGiZs3Y A0VCZ/JHZhiBiB2/7MRSyB7FIRkKBkb47ALkfv9KmfCTbOszUQLURgCsckkyVtuljXOR T63PHJt3JR4e4MvygfII/ddGbUISN86QOFxSg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N8QYerXEaqWdfHlNx6gpLi8IwzqsBwOqOFk9N60B1+Q=; b=hx0BVY/PEpOAJBtEuJJdTg6Xox86AgDCeLml834TvYtmUCEjpZO4i475NDXp8i+1hp 4OItzELdTHBf1y0GpWE9XropsJZKy01wfBoaWRJZx0f4t1ag4tpbL3feTmpaAyxURLaC t98RhAyqAiwax1lKHkv7nG32ylbGixC+qlYztdMBdh82a/2zPooOEKRhEbINpibA1nDV 49Fp5eCIw0Yu5nKzUf4PQ+zFL+Aqymu3zTueR0keTaZOfqQCg5aSqjWGb00R+wvuVhhy fxDNlSVvP6xGH9tbqlrcDwGXhgRKaGiyuTz1eSD2S4RqYm5U9WRT2bB3n8TJ3fQcA0UA BdRg== X-Gm-Message-State: ABuFfoin4wdhox5DVEiVoaG44VF0eVwaa5n0RBJ2qlzbb1seIJyOMV3F 9u6p7HH7Kj3CxiJoUHYp3QRIkQ== X-Received: by 2002:a62:7501:: with SMTP id q1-v6mr15046736pfc.225.1538117320761; Thu, 27 Sep 2018 23:48:40 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id m21-v6sm5869051pgd.6.2018.09.27.23.48.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 23:48:39 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, dhowells@redhat.com, vgoyal@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, dyoung@redhat.com, bhe@redhat.com, arnd@arndb.de, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com Cc: prudo@linux.ibm.com, ard.biesheuvel@linaro.org, james.morse@arm.com, bhsharma@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v15 09/16] arm64: enable KEXEC_FILE config Date: Fri, 28 Sep 2018 15:48:34 +0900 Message-Id: <20180928064841.14117-10-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180928064841.14117-1-takahiro.akashi@linaro.org> References: <20180928064841.14117-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Modify arm64/Kconfig to enable kexec_file_load support. Signed-off-by: AKASHI Takahiro Cc: Catalin Marinas Cc: Will Deacon Acked-by: James Morse --- arch/arm64/Kconfig | 9 +++++++++ arch/arm64/kernel/Makefile | 3 ++- arch/arm64/kernel/machine_kexec_file.c | 16 ++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/kernel/machine_kexec_file.c -- 2.19.0 diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 1b1a0e95c751..5eb18d0cb513 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -843,6 +843,15 @@ config KEXEC but it is independent of the system firmware. And like a reboot you can start any kernel with it, not just Linux. +config KEXEC_FILE + bool "kexec file based system call" + select KEXEC_CORE + help + This is new version of kexec system call. This system call is + file based and takes file descriptors as system call argument + for kernel and initramfs as opposed to list of segments as + accepted by previous system call. + config CRASH_DUMP bool "Build kdump crash kernel" help diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 4c8b13bede80..030a39bff117 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -49,8 +49,9 @@ arm64-obj-$(CONFIG_ARM64_ACPI_PARKING_PROTOCOL) += acpi_parking_protocol.o arm64-obj-$(CONFIG_PARAVIRT) += paravirt.o arm64-obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.o arm64-obj-$(CONFIG_HIBERNATION) += hibernate.o hibernate-asm.o -arm64-obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o \ +arm64-obj-$(CONFIG_KEXEC_CORE) += machine_kexec.o relocate_kernel.o \ cpu-reset.o +arm64-obj-$(CONFIG_KEXEC_FILE) += machine_kexec_file.o arm64-obj-$(CONFIG_ARM64_RELOC_TEST) += arm64-reloc-test.o arm64-reloc-test-y := reloc_test_core.o reloc_test_syms.o arm64-obj-$(CONFIG_CRASH_DUMP) += crash_dump.o diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c new file mode 100644 index 000000000000..c38a8048ed00 --- /dev/null +++ b/arch/arm64/kernel/machine_kexec_file.c @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * kexec_file for arm64 + * + * Copyright (C) 2018 Linaro Limited + * Author: AKASHI Takahiro + * + */ + +#define pr_fmt(fmt) "kexec_file: " fmt + +#include + +const struct kexec_file_ops * const kexec_file_loaders[] = { + NULL +}; From patchwork Fri Sep 28 06:48:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 147776 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp371613lji; Thu, 27 Sep 2018 23:49:00 -0700 (PDT) X-Google-Smtp-Source: ACcGV62eKGXIuhSEqH349ZsR02Q38KfhNFGRB5U4YtPKOdEPImx46oqS961MYE3CRRsBA3boolkQ X-Received: by 2002:a63:4443:: with SMTP id t3-v6mr13603435pgk.102.1538117339890; Thu, 27 Sep 2018 23:48:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538117339; cv=none; d=google.com; s=arc-20160816; b=cXtMLqQXt9a4zd2Zo06LuymKFk4k57HvEd3ZT+a3B2UC7xlA866uhmapFAfD7iyuzy IcLlvkHi1nePulPTmQ4IRhLe8qVa+ZxT3KMnzIsSP3BrDW4HzbzWsJw7opnJVKB0Bg53 Dg4WxUsFNnrzB9eI2IeeOkOefX8HcBGHzh8TEgVHxdIYy4XOyyNSK+8RcuYPqMGSfGp+ C5ZNaW76QPbHHOe9abUDeYLmFs6RE8gSuFLYFKB+7UNn7FwfOfrv6QdsD5xv+8IL+NC0 FMrm2zowwZhMidydu9yIfP6Rg4rxmnYgRp1B1Hlx+2H9LnLxyAxXOhnNEHtmzixYPd71 DBzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vzr4R2Cq+6LI3NmBny8qeM6kKSI6IrCINci/4DwDurI=; b=Wn9/I0OSsUy2Rsj0jb0ugXP0nQcWv6FHxCtLq1ogUWTSQDyPGouBmtnWk/4ZqPmDQx ynpG26d9l6R/vop8TpTC6Kr0PEPO8wfIOPRf4ezHpO8WyuytNn/zbXxMv1qot+nmwR9g n5FnFyyBoEwZ5NpyCIlGT+BYiDUKyonNN4MCnXeWXFwqJelqNkQBb3AylftGJ3tsIOVj K6QvpPrgi4719DM19j236/XBrhU3qfhFbH6TWFC40rVojw1Ok0tfI59e+QmlfkG+3tyD ENAFj5GZo5Da8xsYx5JlDYH1YqD9THcWhA5KPhPxvpjzo0mIzx8g3hKqV8b7aw+yi2KK dZGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NmzOBt9S; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d7-v6si3987407plo.418.2018.09.27.23.48.59; Thu, 27 Sep 2018 23:48:59 -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=@linaro.org header.s=google header.b=NmzOBt9S; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729152AbeI1NLM (ORCPT + 32 others); Fri, 28 Sep 2018 09:11:12 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:39033 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbeI1NLL (ORCPT ); Fri, 28 Sep 2018 09:11:11 -0400 Received: by mail-pg1-f193.google.com with SMTP id 85-v6so3729080pge.6 for ; Thu, 27 Sep 2018 23:48:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vzr4R2Cq+6LI3NmBny8qeM6kKSI6IrCINci/4DwDurI=; b=NmzOBt9SYJiINTopNWJxES3Ii8Ip9h3YBRbfaMCfqDxr+8HgduY2+snZV3WvaKyjno jDgQ16BL5b0xBDer5t1T3srjxKkpSzcni4ev0szNZIZPI4/jnkEEoULsl0tM6bfFznQ9 0JtluZuWp7YbRG6fdx4+uCgn1rGy1WS7XfLGY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vzr4R2Cq+6LI3NmBny8qeM6kKSI6IrCINci/4DwDurI=; b=XdBPkLxfXj9Kf74eHxkzHVyU80eeY1WIsWmPni2K0a5tYf855BtiYPH0qwPq5z2aXw j0gEQXf7GppYAXXriBhz7xOXoC4+ufmkAdHttPHEEPZWw/5G3sKo+T1/JpeLo7AXNbhP zGUjTolCo1Yla4OV7MZ+5DI53CeEUxOosA06ySMAFXe7fTS2uxC55i34SQ/aZ5jgIEs+ SyzXX83w1liyzy+EeFOrvg9pPPwMeMM2Fagf8Yh9gEMXvT0L9xp0lpjm4HOjIduBiP9g 3CcYLMV6Lj+I8Fa8jDSOU/ABJQ4pR3s9AI4tN2uVXUkmDcKHLQ1BuYXpsBZDc1viS8ZL 9Yzw== X-Gm-Message-State: ABuFfoj3/oP91/fDtw7XHHed6Bb8I++62K1Ll0UPrc4QjXbXJ30V+l6o rAOMF5L8qOtyNLd/7uiOIzLrrg== X-Received: by 2002:a62:2646:: with SMTP id m67-v6mr15207110pfm.254.1538117336614; Thu, 27 Sep 2018 23:48:56 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id f6-v6sm5316468pgf.52.2018.09.27.23.48.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 23:48:55 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, dhowells@redhat.com, vgoyal@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, dyoung@redhat.com, bhe@redhat.com, arnd@arndb.de, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com Cc: prudo@linux.ibm.com, ard.biesheuvel@linaro.org, james.morse@arm.com, bhsharma@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v15 10/16] arm64: kexec_file: load initrd and device-tree Date: Fri, 28 Sep 2018 15:48:35 +0900 Message-Id: <20180928064841.14117-11-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180928064841.14117-1-takahiro.akashi@linaro.org> References: <20180928064841.14117-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org load_other_segments() is expected to allocate and place all the necessary memory segments other than kernel, including initrd and device-tree blob (and elf core header for crash). While most of the code was borrowed from kexec-tools' counterpart, users may not be allowed to specify dtb explicitly, instead, the dtb presented by the original boot loader is reused. arch_kimage_kernel_post_load_cleanup() is responsible for freeing arm64- specific data allocated in load_other_segments(). Signed-off-by: AKASHI Takahiro Cc: Catalin Marinas Cc: Will Deacon Reviewed-by: James Morse --- arch/arm64/include/asm/kexec.h | 17 +++ arch/arm64/kernel/machine_kexec_file.c | 188 +++++++++++++++++++++++++ 2 files changed, 205 insertions(+) -- 2.19.0 diff --git a/arch/arm64/include/asm/kexec.h b/arch/arm64/include/asm/kexec.h index e17f0529a882..157b2897d911 100644 --- a/arch/arm64/include/asm/kexec.h +++ b/arch/arm64/include/asm/kexec.h @@ -93,6 +93,23 @@ static inline void crash_prepare_suspend(void) {} static inline void crash_post_resume(void) {} #endif +#ifdef CONFIG_KEXEC_FILE +#define ARCH_HAS_KIMAGE_ARCH + +struct kimage_arch { + void *dtb; + unsigned long dtb_mem; +}; + +struct kimage; + +extern int arch_kimage_file_post_load_cleanup(struct kimage *image); +extern int load_other_segments(struct kimage *image, + unsigned long kernel_load_addr, unsigned long kernel_size, + char *initrd, unsigned long initrd_len, + char *cmdline, unsigned long cmdline_len); +#endif + #endif /* __ASSEMBLY__ */ #endif diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c index c38a8048ed00..f53f14bd1700 100644 --- a/arch/arm64/kernel/machine_kexec_file.c +++ b/arch/arm64/kernel/machine_kexec_file.c @@ -5,12 +5,200 @@ * Copyright (C) 2018 Linaro Limited * Author: AKASHI Takahiro * + * Most code is derived from arm64 port of kexec-tools */ #define pr_fmt(fmt) "kexec_file: " fmt +#include +#include #include +#include +#include +#include +#include +#include + +/* relevant device tree properties */ +#define FDT_PSTR_INITRD_STA "linux,initrd-start" +#define FDT_PSTR_INITRD_END "linux,initrd-end" +#define FDT_PSTR_BOOTARGS "bootargs" const struct kexec_file_ops * const kexec_file_loaders[] = { NULL }; + +int arch_kimage_file_post_load_cleanup(struct kimage *image) +{ + vfree(image->arch.dtb); + image->arch.dtb = NULL; + + return kexec_image_post_load_cleanup_default(image); +} + +static int setup_dtb(struct kimage *image, + unsigned long initrd_load_addr, unsigned long initrd_len, + char *cmdline, unsigned long cmdline_len, + void **dtb_buf, unsigned long *dtb_buf_len) +{ + void *buf = NULL; + size_t buf_size; + int nodeoffset; + int ret; + + /* duplicate dt blob */ + buf_size = fdt_totalsize(initial_boot_params); + + if (initrd_load_addr) { + /* can be redundant, but trimmed at the end */ + buf_size += fdt_prop_len(FDT_PSTR_INITRD_STA, sizeof(u64)); + buf_size += fdt_prop_len(FDT_PSTR_INITRD_END, sizeof(u64)); + } + + if (cmdline) + /* can be redundant, but trimmed at the end */ + buf_size += fdt_prop_len(FDT_PSTR_BOOTARGS, cmdline_len); + + buf = vmalloc(buf_size); + if (!buf) { + ret = -ENOMEM; + goto out_err; + } + + ret = fdt_open_into(initial_boot_params, buf, buf_size); + if (ret) { + ret = -EINVAL; + goto out_err; + } + + nodeoffset = fdt_path_offset(buf, "/chosen"); + if (nodeoffset < 0) { + ret = -EINVAL; + goto out_err; + } + + /* add bootargs */ + if (cmdline) { + ret = fdt_setprop_string(buf, nodeoffset, FDT_PSTR_BOOTARGS, + cmdline); + if (ret) { + ret = -EINVAL; + goto out_err; + } + } else { + ret = fdt_delprop(buf, nodeoffset, FDT_PSTR_BOOTARGS); + if (ret && (ret != -FDT_ERR_NOTFOUND)) { + ret = -EINVAL; + goto out_err; + } + } + + /* add initrd-* */ + if (initrd_load_addr) { + ret = fdt_setprop_u64(buf, nodeoffset, FDT_PSTR_INITRD_STA, + initrd_load_addr); + if (ret) { + ret = -EINVAL; + goto out_err; + } + + ret = fdt_setprop_u64(buf, nodeoffset, FDT_PSTR_INITRD_END, + initrd_load_addr + initrd_len); + if (ret) { + ret = -EINVAL; + goto out_err; + } + } else { + ret = fdt_delprop(buf, nodeoffset, FDT_PSTR_INITRD_STA); + if (ret && (ret != -FDT_ERR_NOTFOUND)) { + ret = -EINVAL; + goto out_err; + } + + ret = fdt_delprop(buf, nodeoffset, FDT_PSTR_INITRD_END); + if (ret && (ret != -FDT_ERR_NOTFOUND)) { + ret = -EINVAL; + goto out_err; + } + } + + /* trim a buffer */ + fdt_pack(buf); + *dtb_buf = buf; + *dtb_buf_len = fdt_totalsize(buf); + + return 0; + +out_err: + vfree(buf); + return ret; +} + +int load_other_segments(struct kimage *image, + unsigned long kernel_load_addr, + unsigned long kernel_size, + char *initrd, unsigned long initrd_len, + char *cmdline, unsigned long cmdline_len) +{ + struct kexec_buf kbuf; + void *dtb = NULL; + unsigned long initrd_load_addr = 0, dtb_len; + int ret = 0; + + kbuf.image = image; + /* not allocate anything below the kernel */ + kbuf.buf_min = kernel_load_addr + kernel_size; + + /* load initrd */ + if (initrd) { + kbuf.buffer = initrd; + kbuf.bufsz = initrd_len; + kbuf.mem = 0; + kbuf.memsz = initrd_len; + kbuf.buf_align = 0; + /* within 1GB-aligned window of up to 32GB in size */ + kbuf.buf_max = round_down(kernel_load_addr, SZ_1G) + + (unsigned long)SZ_1G * 32; + kbuf.top_down = false; + + ret = kexec_add_buffer(&kbuf); + if (ret) + goto out_err; + initrd_load_addr = kbuf.mem; + + pr_debug("Loaded initrd at 0x%lx bufsz=0x%lx memsz=0x%lx\n", + initrd_load_addr, initrd_len, initrd_len); + } + + /* load dtb blob */ + ret = setup_dtb(image, initrd_load_addr, initrd_len, + cmdline, cmdline_len, &dtb, &dtb_len); + if (ret) { + pr_err("Preparing for new dtb failed\n"); + goto out_err; + } + + kbuf.buffer = dtb; + kbuf.bufsz = dtb_len; + kbuf.mem = 0; + kbuf.memsz = dtb_len; + /* not across 2MB boundary */ + kbuf.buf_align = SZ_2M; + kbuf.buf_max = ULONG_MAX; + kbuf.top_down = true; + + ret = kexec_add_buffer(&kbuf); + if (ret) + goto out_err; + image->arch.dtb = dtb; + image->arch.dtb_mem = kbuf.mem; + + pr_debug("Loaded dtb at 0x%lx bufsz=0x%lx memsz=0x%lx\n", + kbuf.mem, dtb_len, dtb_len); + + return 0; + +out_err: + vfree(dtb); + return ret; +} From patchwork Fri Sep 28 06:48:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 147777 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp371732lji; Thu, 27 Sep 2018 23:49:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV626Kk/K/1txbyPZkLaOq7JueGxzGCuXh5KLucb4ne3ZDCW52dbHnQe+mlv42anI1xYCzEMi X-Received: by 2002:a63:cc4f:: with SMTP id q15-v6mr13515208pgi.217.1538117347935; Thu, 27 Sep 2018 23:49:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538117347; cv=none; d=google.com; s=arc-20160816; b=qyO2g5f4aaYnEAFbM2az64QriIQ056k/fPQGd6x5mglCrxhg+CNS2rLH5DIAcOn/j5 /DmpK2T2k5JGZzthpj2m3uCQdJBEHWHEtc/iv65k3uMv2S2pGmJB6xG+iFDUkK0c1RKw O+U8080lgR1eqbqkQAFxjVmMnUzM7XZlcM+Fxlz0/Qh12PHOhzGEFgSPgj9uWh8rWNBz KOWs+4yS6Q2n8nX/7vLxn6rfnwypnMBb0z0ogDRACYchGEQUdIRo4CcxsRIfMqBnjq2F +SVP8adwvQxNm7VgEWxjEQfZXTWRliJeuFg/Ynuo6SNdSc/wYxEoPTIMjKHN0C2NtUw5 13Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gw6DpdgEdV2DBE7O7Gc03v3qbMo6bneJnE0aBac4sK8=; b=gq05c6EJJ0xhsG4+BcOOcvajHcNEEz0btaDrIJST2Aqg/3yQhYkKPUm2uMPt4JkTGy yUh2pueuuT03eIIuuzZhoJsobJHfJCOhtQR1tB41hEcI9WYvANHD7MgDtpxR+MFUJ7mv Gpdna4w1QfaeLrwEEjoIpeAtthqF1+RABINm+Ku2XKeOhtZ4KGHK7j2TmSXtvW+cisbf S5uezHmEOeBmQDHo8GgUHP0iCWNu9eq16/CdSUssq6u3WMB29vNw3OBUSR1hREMf1iau mc9Ib110m5moZMLulfohHTfcEfDb5sqIBiACSWIryxe/T7VGCnwmqQrGI0wilqh8KUUM bp8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LiLd3clS; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m16-v6si3966686pfh.92.2018.09.27.23.49.07; Thu, 27 Sep 2018 23:49:07 -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=@linaro.org header.s=google header.b=LiLd3clS; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729172AbeI1NLT (ORCPT + 32 others); Fri, 28 Sep 2018 09:11:19 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:33028 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbeI1NLT (ORCPT ); Fri, 28 Sep 2018 09:11:19 -0400 Received: by mail-pf1-f193.google.com with SMTP id d4-v6so3655172pfn.0 for ; Thu, 27 Sep 2018 23:49:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gw6DpdgEdV2DBE7O7Gc03v3qbMo6bneJnE0aBac4sK8=; b=LiLd3clShYknPkFbvlOw8zSiZ3fVRzVFhqMxFPLPEts1PMk8QuaFZqU8O3HyH/9Rod Ksbo+V45gS2bLDf8tUJyhQOA4opizyZcKnmLmCfU67W0Dn8bc0K2z9IlJPcCDQX/ssVl NgtfhxevCcg11R3NebgBwz79MUanvpbTJfcOw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gw6DpdgEdV2DBE7O7Gc03v3qbMo6bneJnE0aBac4sK8=; b=klawPis60XXirjrNxCTOuVxLKADdE3ZI0VHJ0FjTU5+oafQX97LiQA5V4nmmT8bnOZ nglIngzuGrmtPpjeNY1R9nTQNanXEud+Zxy/kSuyonN/aOhpoBqy7iK3eEY7M4UP4ux/ 9fuXyuTmpuZRlyQs+tz/duhVsbzH+8ELYadXYc8vJzOijdPCxwEZcmTm1KA1ChgUo0Ya JePl8u3WSzOv+kmsdxqxncgjgb2QCyGd4yTH6n3RpRfulFH7IUOenkLOlFPLOK+pH1Re 85Ga9B6fQZqipkF2ShcJ43hXPHjSBfL1RZiGPVcM9Lo58yl8kQsojNLdp6VvdAQHWAP4 3hww== X-Gm-Message-State: ABuFfogpVd1Mw6hHBg+uOUpLAQ6vxzOydiFF4s66mENCvs/6Cx5PGvJG YVO9CQK4rcc6rgq929qe17FzLQ== X-Received: by 2002:a17:902:784a:: with SMTP id e10-v6mr14612572pln.197.1538117343963; Thu, 27 Sep 2018 23:49:03 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id j27-v6sm7623704pfj.91.2018.09.27.23.49.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 23:49:02 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, dhowells@redhat.com, vgoyal@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, dyoung@redhat.com, bhe@redhat.com, arnd@arndb.de, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com Cc: prudo@linux.ibm.com, ard.biesheuvel@linaro.org, james.morse@arm.com, bhsharma@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v15 11/16] arm64: kexec_file: allow for loading Image-format kernel Date: Fri, 28 Sep 2018 15:48:36 +0900 Message-Id: <20180928064841.14117-12-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180928064841.14117-1-takahiro.akashi@linaro.org> References: <20180928064841.14117-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch provides kexec_file_ops for "Image"-format kernel. In this implementation, a binary is always loaded with a fixed offset identified in text_offset field of its header. Regarding signature verification for trusted boot, this patch doesn't contains CONFIG_KEXEC_VERIFY_SIG support, which is to be added later in this series, but file-attribute-based verification is still a viable option by enabling IMA security subsystem. You can sign(label) a to-be-kexec'ed kernel image on target file system with: $ evmctl ima_sign --key /path/to/private_key.pem Image On live system, you must have IMA enforced with, at least, the following security policy: "appraise func=KEXEC_KERNEL_CHECK appraise_type=imasig" See more details about IMA here: https://sourceforge.net/p/linux-ima/wiki/Home/ Signed-off-by: AKASHI Takahiro Cc: Catalin Marinas Cc: Will Deacon Reviewed-by: James Morse --- arch/arm64/include/asm/kexec.h | 28 +++++++ arch/arm64/kernel/Makefile | 2 +- arch/arm64/kernel/kexec_image.c | 108 +++++++++++++++++++++++++ arch/arm64/kernel/machine_kexec_file.c | 1 + 4 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/kernel/kexec_image.c -- 2.19.0 diff --git a/arch/arm64/include/asm/kexec.h b/arch/arm64/include/asm/kexec.h index 157b2897d911..5e673481b3a3 100644 --- a/arch/arm64/include/asm/kexec.h +++ b/arch/arm64/include/asm/kexec.h @@ -101,6 +101,34 @@ struct kimage_arch { unsigned long dtb_mem; }; +/** + * struct arm64_image_header - arm64 kernel image header + * See Documentation/arm64/booting.txt for details + * + * @mz_magic: DOS header magic number ('MZ', optional) + * @code1: Instruction (branch to stext) + * @text_offset: Image load offset + * @image_size: Effective image size + * @flags: Bit-field flags + * @reserved: Reserved + * @magic: Magic number + * @pe_header: Offset to PE COFF header (optional) + **/ + +struct arm64_image_header { + __le16 mz_magic; /* also code0 */ + __le16 pad; + __le32 code1; + __le64 text_offset; + __le64 image_size; + __le64 flags; + __le64 reserved[3]; + __le32 magic; + __le32 pe_header; +}; + +extern const struct kexec_file_ops kexec_image_ops; + struct kimage; extern int arch_kimage_file_post_load_cleanup(struct kimage *image); diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 030a39bff117..48868255f09c 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -51,7 +51,7 @@ arm64-obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.o arm64-obj-$(CONFIG_HIBERNATION) += hibernate.o hibernate-asm.o arm64-obj-$(CONFIG_KEXEC_CORE) += machine_kexec.o relocate_kernel.o \ cpu-reset.o -arm64-obj-$(CONFIG_KEXEC_FILE) += machine_kexec_file.o +arm64-obj-$(CONFIG_KEXEC_FILE) += machine_kexec_file.o kexec_image.o arm64-obj-$(CONFIG_ARM64_RELOC_TEST) += arm64-reloc-test.o arm64-reloc-test-y := reloc_test_core.o reloc_test_syms.o arm64-obj-$(CONFIG_CRASH_DUMP) += crash_dump.o diff --git a/arch/arm64/kernel/kexec_image.c b/arch/arm64/kernel/kexec_image.c new file mode 100644 index 000000000000..d64f5e9f9d22 --- /dev/null +++ b/arch/arm64/kernel/kexec_image.c @@ -0,0 +1,108 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Kexec image loader + + * Copyright (C) 2018 Linaro Limited + * Author: AKASHI Takahiro + */ + +#define pr_fmt(fmt) "kexec_file(Image): " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int image_probe(const char *kernel_buf, unsigned long kernel_len) +{ + const struct arm64_image_header *h; + + h = (const struct arm64_image_header *)(kernel_buf); + + if (!h || (kernel_len < sizeof(*h)) || + memcmp(&h->magic, ARM64_MAGIC, sizeof(h->magic))) + return -EINVAL; + + return 0; +} + +static void *image_load(struct kimage *image, + char *kernel, unsigned long kernel_len, + char *initrd, unsigned long initrd_len, + char *cmdline, unsigned long cmdline_len) +{ + struct arm64_image_header *h; + u64 flags, value; + struct kexec_buf kbuf; + unsigned long text_offset; + struct kexec_segment *kernel_segment; + int ret; + + /* Don't support old kernel */ + h = (struct arm64_image_header *)kernel; + if (!h->text_offset) + return ERR_PTR(-EINVAL); + + /* Check cpu features */ + flags = le64_to_cpu(h->flags); + value = head_flag_field(flags, HEAD_FLAG_BE); + if (((value == HEAD_FLAG_BE) && !IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) || + ((value != HEAD_FLAG_BE) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))) + if (!system_supports_mixed_endian()) + return ERR_PTR(-EINVAL); + + value = head_flag_field(flags, HEAD_FLAG_PAGE_SIZE); + if (((value == HEAD_FLAG_PAGE_SIZE_4K) && + !system_supports_4kb_granule()) || + ((value == HEAD_FLAG_PAGE_SIZE_64K) && + !system_supports_64kb_granule()) || + ((value == HEAD_FLAG_PAGE_SIZE_16K) && + !system_supports_16kb_granule())) + return ERR_PTR(-EINVAL); + + /* Load the kernel */ + kbuf.image = image; + kbuf.buf_min = 0; + kbuf.buf_max = ULONG_MAX; + kbuf.top_down = false; + + kbuf.buffer = kernel; + kbuf.bufsz = kernel_len; + kbuf.mem = 0; + kbuf.memsz = le64_to_cpu(h->image_size); + text_offset = le64_to_cpu(h->text_offset); + kbuf.buf_align = MIN_KIMG_ALIGN; + + /* Adjust kernel segment with TEXT_OFFSET */ + kbuf.memsz += text_offset; + + ret = kexec_add_buffer(&kbuf); + if (ret) + return ERR_PTR(ret); + + kernel_segment = &image->segment[image->nr_segments - 1]; + kernel_segment->mem += text_offset; + kernel_segment->memsz -= text_offset; + image->start = kernel_segment->mem; + + pr_debug("Loaded kernel at 0x%lx bufsz=0x%lx memsz=0x%lx\n", + kernel_segment->mem, kbuf.bufsz, + kernel_segment->memsz); + + /* Load additional data */ + ret = load_other_segments(image, + kernel_segment->mem, kernel_segment->memsz, + initrd, initrd_len, cmdline, cmdline_len); + + return ERR_PTR(ret); +} + +const struct kexec_file_ops kexec_image_ops = { + .probe = image_probe, + .load = image_load, +}; diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c index f53f14bd1700..05fb2d4e6fef 100644 --- a/arch/arm64/kernel/machine_kexec_file.c +++ b/arch/arm64/kernel/machine_kexec_file.c @@ -25,6 +25,7 @@ #define FDT_PSTR_BOOTARGS "bootargs" const struct kexec_file_ops * const kexec_file_loaders[] = { + &kexec_image_ops, NULL }; From patchwork Fri Sep 28 06:48:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 147779 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp371995lji; Thu, 27 Sep 2018 23:49:26 -0700 (PDT) X-Google-Smtp-Source: ACcGV63zBhLt1xUaQp2SS/qfDMKsO0K/6sIVZheo3W2CJ2yUd6d5+kClSQxmy2WNSq0DadAMR4yU X-Received: by 2002:a63:ed07:: with SMTP id d7-v6mr13746598pgi.429.1538117366111; Thu, 27 Sep 2018 23:49:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538117366; cv=none; d=google.com; s=arc-20160816; b=kH6hwa3gB1LldzPx6HLLxNI06lRJEeVNE0hq5up2xHRC/qLwYdS8UFDTa2cl2ZWcUz xTGCKuPYWM2eEooMmVSUUkUSMNtUzlPDwknQcxOqZanYrlqrplIlYRb9tzwxHpOKpWCe 15134vjsQ+C8Idpx/m0szbYu5uu5jUnIhPPfYxO+2yOaDtnfwVkVMVZXlg52JE8fX7Sm fpgysU1MLcqtTzbrJdiBjjjedzgUegowxBdtz2gjo1YA0l5SKzj5KeL+dRP2FHkk0nQO rwcZmgsDZUOwb9PFA3FjY9nMDDh+0mVrFfwpC9Iky61GzkCFf6Ov857mEwXfgjv6LQM9 oYxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZdHE4nfr8T5Hxvr10M0CzI0OedYEfMU03IOSvEtlq5c=; b=l8KzRj8A5jG1jeFrc8Wt4IXuVczvcGUjS9wIkgRIOkcr8v/hzEYWOK28uuwISteH2J LDBiQ+B1rddSQXx2ScTTisWNfNl68WChuxzaIpmrzoEAcQJMxLFP6YJ50/lp0svQlwPy F8puI04J9UQl3Q9oQsIG4/1EU+qkR/Gto/4plIKpdtej9emhL9CZe70ALbeRRl7jRRka c2TpxkMkqwbKUSQ87LmVWhFEDinFsuyk7zVt6AAEKEY+hrY0444P1dkZJfQNNc5pkr1E hrRjJUIP7zbFHnScPySk0kwei3ajsjOUvwK8cn18r0fZhl1oq4220DjGYeNKCt0jYOQ8 vfkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Akut7E51; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k135-v6si4639432pfd.168.2018.09.27.23.49.25; Thu, 27 Sep 2018 23:49:26 -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=@linaro.org header.s=google header.b=Akut7E51; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729196AbeI1NLi (ORCPT + 32 others); Fri, 28 Sep 2018 09:11:38 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:34998 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbeI1NLh (ORCPT ); Fri, 28 Sep 2018 09:11:37 -0400 Received: by mail-pf1-f194.google.com with SMTP id p12-v6so3647632pfh.2 for ; Thu, 27 Sep 2018 23:49:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZdHE4nfr8T5Hxvr10M0CzI0OedYEfMU03IOSvEtlq5c=; b=Akut7E51HyMcmoDJ8yq2dxz/1WR22lD8Tli0lJqraJGLfSUeCA7RHO949kC/rxf83y z5MqpcFwckf7HsZYfQldR7Dv1ZCJD6N3/miuWvGM3bGuOiGBs6//wrEYJ4V0HeODh+qP 0F93GU41LJIxZ3fOmJqvU3fiHH1f4dfNr7dkY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZdHE4nfr8T5Hxvr10M0CzI0OedYEfMU03IOSvEtlq5c=; b=s03PgL0jBCBAywYMMiMfigkCohzqP5nvwNOYYM4dVXw/EURZMZNQoMrvB7JA4ymtif k/lWioULCamDRh7ZrsmAyXvGxQ0NoUOmuk410tF6+OnpJ9ObNcKWrpU+jfhCAhIdjSN2 p1LokM+Wq3u6FWJmqgNzAySwGHwwjYpxO1fk+oGo/2Gj0WQgME41f5iioPG9zy4dSi9t OJQf+KZFeARbP7d3RWp4KNkzbbDv5wuT7kihaes8v8WhUN/sfNXFP5OrergrukFeTSKa s4jt/bpWGFcLo+qfFsZPzO+5A/DpbNqVW6Cv8p3VjBEqxWDffyY/ohBNlT2fzL6XMdEy xpBw== X-Gm-Message-State: ABuFfoiHFXJHYgZfb6Tv/EBtEOuj81ElcnTydQiii/I+XNT5ES4140B/ kONCTZ8QWCMgNHD4lvjtyA2Dxw== X-Received: by 2002:a17:902:e088:: with SMTP id cb8-v6mr14600861plb.189.1538117362702; Thu, 27 Sep 2018 23:49:22 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id m27-v6sm6990442pff.187.2018.09.27.23.49.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 23:49:21 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, dhowells@redhat.com, vgoyal@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, dyoung@redhat.com, bhe@redhat.com, arnd@arndb.de, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com Cc: prudo@linux.ibm.com, ard.biesheuvel@linaro.org, james.morse@arm.com, bhsharma@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v15 13/16] arm64: kexec_file: invoke the kernel without purgatory Date: Fri, 28 Sep 2018 15:48:38 +0900 Message-Id: <20180928064841.14117-14-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180928064841.14117-1-takahiro.akashi@linaro.org> References: <20180928064841.14117-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On arm64, purgatory would do almost nothing. So just invoke secondary kernel directly by jumping into its entry code. While, in this case, cpu_soft_restart() must be called with dtb address in the fifth argument, the behavior still stays compatible with kexec_load case as long as the argument is null. Signed-off-by: AKASHI Takahiro Reviewed-by: James Morse Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/kernel/cpu-reset.S | 8 ++++---- arch/arm64/kernel/machine_kexec.c | 12 ++++++++++-- arch/arm64/kernel/relocate_kernel.S | 3 ++- 3 files changed, 16 insertions(+), 7 deletions(-) -- 2.19.0 diff --git a/arch/arm64/kernel/cpu-reset.S b/arch/arm64/kernel/cpu-reset.S index 8021b46c9743..a2be30275a73 100644 --- a/arch/arm64/kernel/cpu-reset.S +++ b/arch/arm64/kernel/cpu-reset.S @@ -22,11 +22,11 @@ * __cpu_soft_restart(el2_switch, entry, arg0, arg1, arg2) - Helper for * cpu_soft_restart. * - * @el2_switch: Flag to indicate a swich to EL2 is needed. + * @el2_switch: Flag to indicate a switch to EL2 is needed. * @entry: Location to jump to for soft reset. - * arg0: First argument passed to @entry. - * arg1: Second argument passed to @entry. - * arg2: Third argument passed to @entry. + * arg0: First argument passed to @entry. (relocation list) + * arg1: Second argument passed to @entry.(physical kernel entry) + * arg2: Third argument passed to @entry. (physical dtb address) * * Put the CPU into the same state as it would be if it had been reset, and * branch to what would be the reset vector. It must be executed with the diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c index 922add8adb74..aa9c94113700 100644 --- a/arch/arm64/kernel/machine_kexec.c +++ b/arch/arm64/kernel/machine_kexec.c @@ -212,9 +212,17 @@ void machine_kexec(struct kimage *kimage) * uses physical addressing to relocate the new image to its final * position and transfers control to the image entry point when the * relocation is complete. + * In kexec case, kimage->start points to purgatory assuming that + * kernel entry and dtb address are embedded in purgatory by + * userspace (kexec-tools). + * In kexec_file case, the kernel starts directly without purgatory. */ - - cpu_soft_restart(reboot_code_buffer_phys, kimage->head, kimage->start, 0); + cpu_soft_restart(reboot_code_buffer_phys, kimage->head, kimage->start, +#ifdef CONFIG_KEXEC_FILE + kimage->arch.dtb_mem); +#else + 0); +#endif BUG(); /* Should never get here. */ } diff --git a/arch/arm64/kernel/relocate_kernel.S b/arch/arm64/kernel/relocate_kernel.S index f407e422a720..95fd94209aae 100644 --- a/arch/arm64/kernel/relocate_kernel.S +++ b/arch/arm64/kernel/relocate_kernel.S @@ -32,6 +32,7 @@ ENTRY(arm64_relocate_new_kernel) /* Setup the list loop variables. */ + mov x18, x2 /* x18 = dtb address */ mov x17, x1 /* x17 = kimage_start */ mov x16, x0 /* x16 = kimage_head */ raw_dcache_line_size x15, x0 /* x15 = dcache line size */ @@ -107,7 +108,7 @@ ENTRY(arm64_relocate_new_kernel) isb /* Start new image. */ - mov x0, xzr + mov x0, x18 mov x1, xzr mov x2, xzr mov x3, xzr From patchwork Fri Sep 28 06:48:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 147780 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp372057lji; Thu, 27 Sep 2018 23:49:30 -0700 (PDT) X-Google-Smtp-Source: ACcGV602YXeowaKr4FobTiPJSzr+cQscMCZGDDMBTDqw0UHCGIuEtLeyIXuklb6GwvjqMjbH5Suj X-Received: by 2002:a17:902:a9cc:: with SMTP id b12-v6mr14502487plr.198.1538117370023; Thu, 27 Sep 2018 23:49:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538117370; cv=none; d=google.com; s=arc-20160816; b=Dl9xEkXJbnz7Gw6vi+p5UHjp634XPq+TJ+RjLpjq8ilTkmNA5saCwzQ17rOUziyX4f KgHr6qXPLw6L/OAw7wZ+Og1GodeUhk9i3aQOEYkikNCPD6Z55Po+gK4Xlr3aSC+E3ME7 5eDmH3+zWUdAGcECCVP+7XJ7XUIKn/weLCRkKBefZq2bFUqysv8TrYVWR1hGPr6ubICu wXD+ZAuXk2iCHpH/dcsFbNJMlhntN++YqDtO0B/6vqGiquMfWGAc/8+MwelTSNscypqw WznYfJGi081yy04H1KkxQOgs7WhTJOim0GWPHsnVkTq958m5yoF/nY7TnnnEOabxV7G+ 3tpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IBZa+UOaDV8TYfXAr244/shDNprkQTt1AVYjh0q1zSg=; b=f+Yb6JoI82pi84kpvF1m6oCsnxzbbg5jm+6m9ndGsyn2W7H4ZZymWZHzMXdjIWz4xh 8YXCK15J9GfUgeJ/98TqN/PlFtLMpObCbCxakAUHg+oW6kUkZF6C8rP0FPHnB1IXGjfb 2x/JvTwxT+Y/pUOXDcDaVBjkTV4U5oxS03pxYAnhny7DoDa43GwUF/ZNFjhnmzD+rZj+ Oig95c+Erq07nmHYWvL+fKt2GfpcgdgSOB3o9INraFLhNpR7DRq395IgSFbGSp5AhWTJ Uf9i+ldVYBmsIT4jCV5G49KAuZUdOZvDndJQLuIhGYMm66VjlCShpElh05RJ73uNr3IR Pyog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Mh2bCx/Z"; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k135-v6si4639432pfd.168.2018.09.27.23.49.29; Thu, 27 Sep 2018 23:49:30 -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=@linaro.org header.s=google header.b="Mh2bCx/Z"; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729211AbeI1NLm (ORCPT + 32 others); Fri, 28 Sep 2018 09:11:42 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:35610 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728765AbeI1NLm (ORCPT ); Fri, 28 Sep 2018 09:11:42 -0400 Received: by mail-pg1-f196.google.com with SMTP id v133-v6so3746627pgb.2 for ; Thu, 27 Sep 2018 23:49:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IBZa+UOaDV8TYfXAr244/shDNprkQTt1AVYjh0q1zSg=; b=Mh2bCx/ZN4Zr/xQdf+Ij2U350YGbZV2r17bFphhhLYuMo7nTEzXYoI8KgK05BStuHg 29FRhfAGp7d3b3cqtE3ewpnaKTCMcgMRrwEW56yUxea7nyOgJ6HWQkIjIbR61Ef6imOo yDiAjpO0CKf4ZkwsS5kiFcYyNa0dYA9L6lr/8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IBZa+UOaDV8TYfXAr244/shDNprkQTt1AVYjh0q1zSg=; b=MvwGo6IImuVFVGZ+tyexgH+TD8SNGWXylHjSLYg19daLPSngHxNcKKZOL2NDLEB4tN P092PACUEWD+7n7UtFxTdfGq8glOmHn6OvGouWq5dcPw4xo6znzZ83Hcf9ieDi4Iv1lC E7hCEv7XhNv8sXi6DD+HS9AS29A/1hX8GNUsoiYFOq/VkguWk69wuBrCRah0p3epwKq9 0uYBiNnN82fZgQHA3nFyE9PObZZZmeEE2V9q62HNWT8vVt5dTkdau4noWtQYnOdYt9mV 4nNH1TSbXLi+tUt/J10QGktOq/O38zAyvqyogdwOKvmnV/FEh/uq1iEWhb2u4hmBtA1K QyUQ== X-Gm-Message-State: ABuFfoi1oNCj/TvwlNZuDYSDxFQ2Dsq7Ap4TQ/ep0EAiEhz1OyyLKfhf tNYKwgI8nBVbaIHU8WNFzoiFXg== X-Received: by 2002:a63:29c6:: with SMTP id p189-v6mr5419584pgp.188.1538117366876; Thu, 27 Sep 2018 23:49:26 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id y128-v6sm5938994pfb.56.2018.09.27.23.49.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 23:49:25 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, dhowells@redhat.com, vgoyal@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, dyoung@redhat.com, bhe@redhat.com, arnd@arndb.de, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com Cc: prudo@linux.ibm.com, ard.biesheuvel@linaro.org, james.morse@arm.com, bhsharma@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v15 14/16] include: pe.h: remove message[] from mz header definition Date: Fri, 28 Sep 2018 15:48:39 +0900 Message-Id: <20180928064841.14117-15-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180928064841.14117-1-takahiro.akashi@linaro.org> References: <20180928064841.14117-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org message[] field won't be part of the definition of mz header. This change is crucial for enabling kexec_file_load on arm64 because arm64's "Image" binary, as in PE format, doesn't have any data for it and accordingly the following check in pefile_parse_binary() will fail: chkaddr(cursor, mz->peaddr, sizeof(*pe)); Signed-off-by: AKASHI Takahiro Reviewed-by: Ard Biesheuvel Cc: David Howells Cc: Vivek Goyal Cc: Herbert Xu Cc: David S. Miller --- include/linux/pe.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.19.0 diff --git a/include/linux/pe.h b/include/linux/pe.h index 143ce75be5f0..3482b18a48b5 100644 --- a/include/linux/pe.h +++ b/include/linux/pe.h @@ -166,7 +166,7 @@ struct mz_hdr { uint16_t oem_info; /* oem specific */ uint16_t reserved1[10]; /* reserved */ uint32_t peaddr; /* address of pe header */ - char message[64]; /* message to print */ + char message[]; /* message to print */ }; struct mz_reloc { From patchwork Fri Sep 28 06:48:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 147781 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp372121lji; Thu, 27 Sep 2018 23:49:34 -0700 (PDT) X-Google-Smtp-Source: ACcGV61DiB/HxKzCjhaifMhSM87QY21QZcSeCVyyCTke7/8Sb3C41mpM3h6w/WwZELoiTJCbVvBq X-Received: by 2002:a62:5543:: with SMTP id j64-v6mr14946114pfb.188.1538117374416; Thu, 27 Sep 2018 23:49:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538117374; cv=none; d=google.com; s=arc-20160816; b=hNI2C7bj7IbiSh9kmFgNFjwnaRhayDb2bxqOQsHFJn4R5jpZSYAYRs35vUxI5wcpsJ klnzZi6SEgdMAKJIpJK+rRYCJu7DIXhWLU08KL/i9PcvEr+HI7pFFlxQHb8JisEKfTDt ho+Tr5Lv48Zzs7Ke/3T9J0FtDGCh7RPdkRXPyRyrreHqOcSyF4Rx8vtrpds9Lng7LbZs zfyIcnA8duQdSkMbwUjfuj3CveW2bn/4Y7ZMd1W3b3OpZdluZ7VqfJthlTw9CNM0eb7K ZFcEGmqpWhVxq+OmHs2z2tPmiG6l07cvgMJTawrlhd7a/eoRMPWygeXBo1rsiwsbJqA8 NqiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/+rOwpZAq7LVQH0becYmXtiL//qU2xu/pSqOkMjD4f0=; b=KxQvQsNQdo/YSgUOcuMhFJfrWKYxzTpv1Ots/4uvwYNoqy/9mSWCfVwuw7vicTRHe8 qbpqvwG2ar2rZuY9qV4fgQxqKKPMSZRrRyvkbGy86zdNapyXM5f45ByY7nxtHqDKQpg6 8Fr+31pvZBFuitPl/PNSUbvK0qNTPBX203iO0C/MHoyCXr4XaPHemvx08B4uJgemtTUi 6N4nYv+R9l7pHNSxVy53MzmcOpLyo74VTBxJAC6K7CJZvMTWr4d3U/M6PnEr1SU9Usd2 O7z88vlZOfXnEkHEG0L21zXktaJ3jIeorAZN/3PFYqZr9fx56d5cD6QX2pV3F58bYcDT qCCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="KB4DyH3/"; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p62-v6si4466842pfj.30.2018.09.27.23.49.34; Thu, 27 Sep 2018 23:49:34 -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=@linaro.org header.s=google header.b="KB4DyH3/"; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729228AbeI1NLr (ORCPT + 32 others); Fri, 28 Sep 2018 09:11:47 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:35010 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728765AbeI1NLq (ORCPT ); Fri, 28 Sep 2018 09:11:46 -0400 Received: by mail-pf1-f193.google.com with SMTP id p12-v6so3647888pfh.2 for ; Thu, 27 Sep 2018 23:49:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/+rOwpZAq7LVQH0becYmXtiL//qU2xu/pSqOkMjD4f0=; b=KB4DyH3/aOOCTeE+ulXend4IlnHljB8l5FxwaLh7zMawvTxl7hXakSbyIdy2GdfBCW TNu6W9rqd6YcC/Kpzk+yYa5fv0ttZ9AtOK1qLnCv7Fg6BTui3hGcYghBqoaFUVpmiYPY HiRibIaRnhkbDmMNt9I9kQiq9lvDDFVFZnlyk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/+rOwpZAq7LVQH0becYmXtiL//qU2xu/pSqOkMjD4f0=; b=ccYjIvUtwIlj3D9Y78rRHa4rB2awbtEJgwszJAX+uI1/ehkEpbxQJzlokDfeTXjep9 Et7xvpMBZgyaLP9UQz9vj5QIViuoOPUyIGMoQQeCosTySSyPOjlDEiKnGfOYpLwQKzq4 86irg46SuWpvLpQ2FqSDMS7CtR8LVexGbpE2cNp7OyuCZA/ZGKoHuMsqG4a6PQRYhcFi FIOmTkq31WnalfypsPU9PqTJf4lsi0DzR2/kdMZ3USQJjkgKJRn4HfCJ5/M3A9j3Jh2T 2p3Mr35SGbL4PGXZW676EzLw4Icdxdsfz7bjYY6qD/Zk9dFoJEw+Dc3/AsqZBY8cNT1y lGlQ== X-Gm-Message-State: ABuFfoiP5NWji3wvpRtPg5TNSJIn/d8nhBbKofRYl8nCMpahbnsykwPG S6eDzjoPfGR3rqh8rJgCVLpZVQ== X-Received: by 2002:a17:902:4e:: with SMTP id 72-v6mr14655909pla.318.1538117371502; Thu, 27 Sep 2018 23:49:31 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id c79-v6sm195047pfc.92.2018.09.27.23.49.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 23:49:30 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, dhowells@redhat.com, vgoyal@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, dyoung@redhat.com, bhe@redhat.com, arnd@arndb.de, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com Cc: prudo@linux.ibm.com, ard.biesheuvel@linaro.org, james.morse@arm.com, bhsharma@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v15 15/16] arm64: kexec_file: add kernel signature verification support Date: Fri, 28 Sep 2018 15:48:40 +0900 Message-Id: <20180928064841.14117-16-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180928064841.14117-1-takahiro.akashi@linaro.org> References: <20180928064841.14117-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With this patch, kernel verification can be done without IMA security subsystem enabled. Turn on CONFIG_KEXEC_VERIFY_SIG instead. On x86, a signature is embedded into a PE file (Microsoft's format) header of binary. Since arm64's "Image" can also be seen as a PE file as far as CONFIG_EFI is enabled, we adopt this format for kernel signing. You can create a signed kernel image with: $ sbsign --key ${KEY} --cert ${CERT} Image Signed-off-by: AKASHI Takahiro Cc: Catalin Marinas Cc: Will Deacon Reviewed-by: James Morse --- arch/arm64/Kconfig | 24 ++++++++++++++++++++++++ arch/arm64/kernel/kexec_image.c | 15 +++++++++++++++ 2 files changed, 39 insertions(+) -- 2.19.0 diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 5eb18d0cb513..e7de9500bf0b 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -852,6 +852,30 @@ config KEXEC_FILE for kernel and initramfs as opposed to list of segments as accepted by previous system call. +config KEXEC_VERIFY_SIG + bool "Verify kernel signature during kexec_file_load() syscall" + depends on KEXEC_FILE + help + Select this option to verify a signature with loaded kernel + image. If configured, any attempt of loading a image without + valid signature will fail. + + In addition to that option, you need to enable signature + verification for the corresponding kernel image type being + loaded in order for this to work. + +config KEXEC_IMAGE_VERIFY_SIG + bool "Enable Image signature verification support" + default y + depends on KEXEC_VERIFY_SIG + depends on EFI && SIGNED_PE_FILE_VERIFICATION + help + Enable Image signature verification support. + +comment "Support for PE file signature verification disabled" + depends on KEXEC_VERIFY_SIG + depends on !EFI || !SIGNED_PE_FILE_VERIFICATION + config CRASH_DUMP bool "Build kdump crash kernel" help diff --git a/arch/arm64/kernel/kexec_image.c b/arch/arm64/kernel/kexec_image.c index d64f5e9f9d22..578d358632d0 100644 --- a/arch/arm64/kernel/kexec_image.c +++ b/arch/arm64/kernel/kexec_image.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -28,6 +29,9 @@ static int image_probe(const char *kernel_buf, unsigned long kernel_len) memcmp(&h->magic, ARM64_MAGIC, sizeof(h->magic))) return -EINVAL; + pr_debug("PE format: %s\n", + memcmp(&h->mz_magic, "MZ", 2) ? "no" : "yes"); + return 0; } @@ -102,7 +106,18 @@ static void *image_load(struct kimage *image, return ERR_PTR(ret); } +#ifdef CONFIG_KEXEC_IMAGE_VERIFY_SIG +static int image_verify_sig(const char *kernel, unsigned long kernel_len) +{ + return verify_pefile_signature(kernel, kernel_len, NULL, + VERIFYING_KEXEC_PE_SIGNATURE); +} +#endif + const struct kexec_file_ops kexec_image_ops = { .probe = image_probe, .load = image_load, +#ifdef CONFIG_KEXEC_IMAGE_VERIFY_SIG + .verify_sig = image_verify_sig, +#endif }; From patchwork Fri Sep 28 06:48:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 147782 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp372161lji; Thu, 27 Sep 2018 23:49:39 -0700 (PDT) X-Google-Smtp-Source: ACcGV63ab3rP6y0iIXx+sT7H2ePzxq5Cdb6TdxsRTxx2Ga8rX/Zfmca8xayFAEtgOFbPppGmHtt8 X-Received: by 2002:a62:8891:: with SMTP id l139-v6mr15049163pfd.198.1538117378996; Thu, 27 Sep 2018 23:49:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538117378; cv=none; d=google.com; s=arc-20160816; b=iyCe8Tf4yLwXddZ9lFXdZua6Ivw+agaucY0FAw8LokKcrxuKTLJ4D93I0w+QCIw3e/ MiIcku+bbYfU/qjyua56HPVCuDusgbtVy0RpTtcdIa+1N4h9pCBHKNmc9H/eQH6/5dFm +mrSx+jAto7f+cSBFPQfryJo+0WN0TRbBv+F2HDqu1HDZqjFBDSS9VnxUEvWJJKHh7Vz BAxWwI1Ewlz01ak6hekZNHfNhqNfEhNTVxQDJRzGIDMOxjbU6wbIIYTOVaHZCIBQ1rDU zP4KRpy3yfwU1WWYiZVn991igJqLspQLX2mZgCECgTRG5pV2TrBpUD3eHaNkcdhgF1KP Hhow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=A1to76Muk1fdla+xjmMFJtb5BFlQOFVgZ1KKX32hm3g=; b=Dw1WdsJux67/ygpTboVvLQsYbI/QtsZkAPao7gn+NgAVGB0xyd+niItbrftkUybOCO ApaU19yJX6QfeAcVOEVuTBb/lhxIAg3hSrtK9M2TibCFUx5g1ptdH/7cj6cB//5lqXz6 Uio/DKiVxXs1X8z9Vnfw5/0ItjYPVc8OJ4Im/bvblOxcWFH0l4T43BwteSjzTQZpvzHw z3cX9M3MhsGuZfWeZ7cBnZkVdsKiNcxCu+cxXD8b/vxBoBQe3oBUasQShBkkFfmcAcbO HvPglul2r6qd9+Yx4Pwz4yP/0cOLxHaxeKDkvWjsu7AZ9/bkzk0R0tm35zYVBP0P6EvL 9Kqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WPP9Dm8h; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t23-v6si4153594plr.48.2018.09.27.23.49.38; Thu, 27 Sep 2018 23:49:38 -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=@linaro.org header.s=google header.b=WPP9Dm8h; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729237AbeI1NLv (ORCPT + 32 others); Fri, 28 Sep 2018 09:11:51 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:36368 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728765AbeI1NLv (ORCPT ); Fri, 28 Sep 2018 09:11:51 -0400 Received: by mail-pf1-f193.google.com with SMTP id b7-v6so3642319pfo.3 for ; Thu, 27 Sep 2018 23:49:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A1to76Muk1fdla+xjmMFJtb5BFlQOFVgZ1KKX32hm3g=; b=WPP9Dm8h5cUbvm4Vfgv7CG3sbSL7MvhM+E7czCqoCAP7d5W0p+jJMUvGc6ekYRON7Q WjHEuVNSOUEXW6cep8nc4kw9iwIZywVej83PvFnvtFRAHMXDWfv8pwR4EjzmQK/Mxkp0 mCmlN2yGuQ9kXGuD2d1zUrHD3hAQAk7WOD/H0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A1to76Muk1fdla+xjmMFJtb5BFlQOFVgZ1KKX32hm3g=; b=H9gHTr7VW7Kp1HeMACiptZ2S5D77PSZTmCiInRlOkjD/sPmndzuuS0Fc20nMQehK6n R9m3JIrZwazThMDWbjZDKfmEHPXvQuk4ss17gV9Hh6TTWZI0KAbl/sp8E6R7OVbzPJE7 FSkcHc52+goYlRfbjLZxp7iAoUb1UqmiFThMwT6KJ+Sy6pfHxBEs0ufr2+2lvhEp2mCC JNl6aefv8rixaIu3PTrOULRXh2xRZ6gNJYQgk4HhMX+00AHju70z07LYUXSfw0vblgUq Vy6nNRYrXMIsMR4QITTZ6HfInatXGczuSj5kpMBQ7/VjJSypEE5ycCoO0KspGTGjM4is CdmA== X-Gm-Message-State: ABuFfojclXGjdVuwFOJnSuu3pnAFhoAeMEWryYYajM+CCdgh6QUTSfkM fJh0GBjo8Ltk1TMcyYra+BD3Og== X-Received: by 2002:a63:5816:: with SMTP id m22-v6mr13507559pgb.332.1538117376233; Thu, 27 Sep 2018 23:49:36 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id r12-v6sm5024997pfh.79.2018.09.27.23.49.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 23:49:35 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, dhowells@redhat.com, vgoyal@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, dyoung@redhat.com, bhe@redhat.com, arnd@arndb.de, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com Cc: prudo@linux.ibm.com, ard.biesheuvel@linaro.org, james.morse@arm.com, bhsharma@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v15 16/16] arm64: kexec_file: add kaslr support Date: Fri, 28 Sep 2018 15:48:41 +0900 Message-Id: <20180928064841.14117-17-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180928064841.14117-1-takahiro.akashi@linaro.org> References: <20180928064841.14117-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding "kaslr-seed" to dtb enables triggering kaslr, or kernel virtual address randomization, at secondary kernel boot. We always do this as it will have no harm on kaslr-incapable kernel. We don't have any "switch" to turn off this feature directly, but still can suppress it by passing "nokaslr" as a kernel boot argument. Signed-off-by: AKASHI Takahiro Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/kernel/machine_kexec_file.c | 45 ++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) -- 2.19.0 diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c index 4b5ea256c84c..c2ca7c921e7a 100644 --- a/arch/arm64/kernel/machine_kexec_file.c +++ b/arch/arm64/kernel/machine_kexec_file.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -27,6 +28,7 @@ #define FDT_PSTR_INITRD_STA "linux,initrd-start" #define FDT_PSTR_INITRD_END "linux,initrd-end" #define FDT_PSTR_BOOTARGS "bootargs" +#define FDT_PSTR_KASLR_SEED "kaslr-seed" const struct kexec_file_ops * const kexec_file_loaders[] = { &kexec_image_ops, @@ -45,6 +47,32 @@ int arch_kimage_file_post_load_cleanup(struct kimage *image) return kexec_image_post_load_cleanup_default(image); } +/* crng needs to have been initialized for providing kaslr-seed */ +static int random_ready; + +static void random_ready_notified(struct random_ready_callback *unused) +{ + random_ready = 1; +} + +static struct random_ready_callback random_ready_cb = { + .func = random_ready_notified, +}; + +static __init int init_random_ready_cb(void) +{ + int ret; + + ret = add_random_ready_callback(&random_ready_cb); + if (ret == -EALREADY) + random_ready = 1; + else if (ret) + pr_warn("failed to add a callback for random_ready\n"); + + return 0; +} +late_initcall(init_random_ready_cb) + static int setup_dtb(struct kimage *image, unsigned long initrd_load_addr, unsigned long initrd_len, char *cmdline, unsigned long cmdline_len, @@ -54,6 +82,7 @@ static int setup_dtb(struct kimage *image, int addr_cells, size_cells; size_t buf_size, range_size; int nodeoffset; + u64 value; int ret; /* duplicate dt blob */ @@ -81,6 +110,8 @@ static int setup_dtb(struct kimage *image, /* can be redundant, but trimmed at the end */ buf_size += fdt_prop_len(FDT_PSTR_BOOTARGS, cmdline_len); + buf_size += fdt_prop_len(FDT_PSTR_KASLR_SEED, sizeof(u64)); + buf = vmalloc(buf_size); if (!buf) { ret = -ENOMEM; @@ -160,6 +191,20 @@ static int setup_dtb(struct kimage *image, } } + /* add kaslr-seed */ + fdt_delprop(buf, nodeoffset, FDT_PSTR_KASLR_SEED); + if (random_ready) { + get_random_bytes(&value, sizeof(value)); + ret = fdt_setprop_u64(buf, nodeoffset, FDT_PSTR_KASLR_SEED, + value); + if (ret) { + ret = -EINVAL; + goto out_err; + } + } else { + pr_notice("kaslr-seed won't be fed\n"); + } + /* trim a buffer */ fdt_pack(buf); *dtb_buf = buf;