From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756870AbcHVWVT (ORCPT ); Mon, 22 Aug 2016 18:21:19 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:27342 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756749AbcHVWVR (ORCPT ); Mon, 22 Aug 2016 18:21:17 -0400 X-IBM-Helo: d24dlp01.br.ibm.com X-IBM-MailFrom: bauerman@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org;linux-security-module@vger.kernel.org From: Thiago Jung Bauermann To: Dave Young Cc: kexec@lists.infradead.org, Benjamin Herrenschmidt , Balbir Singh , Paul Mackerras , "H. Peter Anvin" , linux-ima-devel@lists.sourceforge.net, Stewart Smith , Baoquan He , Michael Ellerman , x86@kernel.org, Ingo Molnar , Mimi Zohar , Vivek Goyal , Petko Manolov , Thomas Gleixner , Eric Richter , linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, David Laight , Eric Biederman , Andrew Morton , Samuel Mendoza-Jonas , linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH v2 2/6] powerpc: kexec_file: Add buffer hand-over support for the next kernel Date: Mon, 22 Aug 2016 19:21:09 -0300 User-Agent: KMail/4.14.3 (Linux/3.13.0-93-generic; KDE/4.14.13; x86_64; ; ) In-Reply-To: <20160822072200.GA32673@dhcp-128-65.nay.redhat.com> References: <1471058305-30198-1-git-send-email-bauerman@linux.vnet.ibm.com> <5233171.lLzbU6ABRT@hactar> <20160822072200.GA32673@dhcp-128-65.nay.redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16082222-0020-0000-0000-00000232F305 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16082222-0021-0000-0000-000030205C91 Message-Id: <1796099.kfo9Nk8t61@hactar> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-08-22_13:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1608220222 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Montag, 22 August 2016, 15:22:00 schrieb Dave Young: > On 08/22/16 at 12:38am, Thiago Jung Bauermann wrote: > > Am Montag, 22 August 2016, 11:21:35 schrieb Dave Young: > > > On 08/13/16 at 12:18am, Thiago Jung Bauermann wrote: > > > > diff --git a/arch/powerpc/kernel/machine_kexec_64.c > > > > b/arch/powerpc/kernel/machine_kexec_64.c index > > > > a484a6346146..190c652e49b7 100644 > > > > --- a/arch/powerpc/kernel/machine_kexec_64.c > > > > +++ b/arch/powerpc/kernel/machine_kexec_64.c > > > > @@ -490,6 +490,60 @@ int arch_kimage_file_post_load_cleanup(struct > > > > kimage *image)> > > > > > > > > return image->fops->cleanup(image->image_loader_data); > > > > > > > > } > > > > > > > > +bool kexec_can_hand_over_buffer(void) > > > > +{ > > > > + return true; > > > > +} > > > > + > > > > +int arch_kexec_add_handover_buffer(struct kimage *image, > > > > + unsigned long load_addr, unsigned long > > > > size) > > > > > > +{ > > > > + image->arch.handover_buffer_addr = load_addr; > > > > + image->arch.handover_buffer_size = size; > > > > + > > > > + return 0; > > > > +} > > > > + > > > > +int kexec_get_handover_buffer(void **addr, unsigned long *size) > > > > +{ > > > > + int ret; > > > > + u64 start_addr, end_addr; > > > > + > > > > + ret = of_property_read_u64(of_chosen, > > > > + "linux,kexec-handover-buffer- start", > > > > + &start_addr); > > > > + if (ret == -EINVAL) > > > > + return -ENOENT; > > > > + else if (ret) > > > > + return -EINVAL; > > > > + > > > > + ret = of_property_read_u64(of_chosen, > > > > "linux,kexec-handover-buffer-end", + > > > > &end_addr); > > > > > > + if (ret == -EINVAL) > > > > + return -ENOENT; > > > > + else if (ret) > > > > + return -EINVAL; > > > > + > > > > + *addr = __va(start_addr); > > > > + /* -end is the first address after the buffer. */ > > > > + *size = end_addr - start_addr; > > > > + > > > > + return 0; > > > > +} > > > > > > This depends on dtb, so if IMA want to extend it to arches like x86 in > > > the future you will have to think about other way to pass it. > > > > > > How about think about a general way now? > > > > The only general way I can think of is by adding a kernel command line > > parameter which the first kernel would pass to the second kernel, but > > IMHO that is ugly, because such parameter wouldn't be useful to a user, > > and it would also be something that, from the perspective of the user, > > would magically appear in the kernel command line of the second > > kernel... > Sorry I just brought up the question, actually I have no idea either. > Maybe we have to do this with arch specific ways.. Actually, I don't think it's possible to avoid arch-specific code because the first kernel has to put the buffer memory region in a reserved memory map, and that is arch-specific. On powerpc, this is done by adding it to the device tree memory reservation map. On x86, I believe this would be done added to the e820 map. -- []'s Thiago Jung Bauermann IBM Linux Technology Center