From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 39C5AC48BEB for ; Wed, 21 Feb 2024 20:24:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Mime-Version:References:In-Reply-To: Date:Cc:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dzAGdaWwhbsxgwXmP4lkH34jJp3t9e95DAohUnhQrjc=; b=EyGqCqaDhL+KSZ g54LBnC6L0Cf64OdyUSJuDm4us51ZU+A7Oucn1cXKadIYwS+l6WaHt9NcoVWhQ0aWBQwDQj/Mti3H ixRZZeFzC1wAzcBXz6lwLrRo4CiUTj0FuDJOw6xnBJi+1WyyfTQIckE8++dmRAMEpPRxgsDacnNks t7O5Xl+hw4XKaQRNNirNW4Vf2dah1EpMgKynUJA2etYnxFNiBGLU16Te0vnK0ZSSMXPWsxIKJOanm FunXQOhsTIqlYDKvbxwInzYnA32ly1U/IZb/u6RU7Q3I0CgOdaLDwxPNX2Uj/8VJ1lJjwOqZ2oWk3 eYhUu02VGuX5Qmudd0Gg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rct8K-00000002TNk-2Sze; Wed, 21 Feb 2024 20:24:00 +0000 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rct8H-00000002TNO-1fCQ for kexec@lists.infradead.org; Wed, 21 Feb 2024 20:23:59 +0000 Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41LJdQfr010547; Wed, 21 Feb 2024 20:23:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : subject : from : to : cc : date : in-reply-to : references : content-type : mime-version : content-transfer-encoding; s=pp1; bh=H0Knshgb/5Hes+ApBhBaRoQ2QNjfzNSdXlyo1Kv8i8Q=; b=e4Cjo1wkSqIQVEUvV5p2qSHtjW9Yiy/iW/OjXEdQpYIpHTGxX2sNGdb/dSgsI/LXM4FZ RzuWLma5VGB5UrsLNTsC+Krxu3sdsBdR1CrPKHZQRbSxXET8ICE5EFAscbEg8eaCxfnK RT8ODyHnKhs3BfPLT3vqXnLM1LuTDZBALxUOqdq7Tz2A8ujPCzPJ5WNPBLJnjg1zKb9G 70yVeXDzwQaFkCHzXoSWpmcGFEGBMC2LVKR7RlpkoCxt5FjVB4hbgCD71RAfvuz6fJyl zIOYnWSwfECSwy3kkuV/t12EBPhZD9xrKDRn3m/X2++ckurMeGJav73bg41p0Wq7QkhN UA== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wdqh70u0f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 21 Feb 2024 20:23:11 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 41LJ62hi003671; Wed, 21 Feb 2024 20:23:10 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wb74tsvug-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 21 Feb 2024 20:23:10 +0000 Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41LKN8wb18678480 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Feb 2024 20:23:10 GMT Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EEC355805A; Wed, 21 Feb 2024 20:23:07 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0FA955803F; Wed, 21 Feb 2024 20:23:07 +0000 (GMT) Received: from li-5cd3c5cc-21f9-11b2-a85c-a4381f30c2f3.watson.ibm.com (unknown [9.31.110.109]) by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 21 Feb 2024 20:23:06 +0000 (GMT) Message-ID: <210e2579031b46afd3c8b39917ff535508d66866.camel@linux.ibm.com> Subject: Re: [PATCH v5 2/8] kexec: define functions to map and unmap segments From: Mimi Zohar To: Tushar Sugandhi , roberto.sassu@huaweicloud.com, roberto.sassu@huawei.com, eric.snowberg@oracle.com, stefanb@linux.ibm.com, ebiederm@xmission.com, noodles@fb.com, bauermann@kolabnow.com, linux-integrity@vger.kernel.org, kexec@lists.infradead.org Cc: code@tyhicks.com, nramas@linux.microsoft.com, paul@paul-moore.com Date: Wed, 21 Feb 2024 15:22:51 -0500 In-Reply-To: <20240214153827.1087657-3-tusharsu@linux.microsoft.com> References: <20240214153827.1087657-1-tusharsu@linux.microsoft.com> <20240214153827.1087657-3-tusharsu@linux.microsoft.com> X-Mailer: Evolution 3.28.5 (3.28.5-22.el8) Mime-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Lw4GAElcCbfVd3gKmyerDV5udUzy05nU X-Proofpoint-GUID: Lw4GAElcCbfVd3gKmyerDV5udUzy05nU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-21_07,2024-02-21_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 suspectscore=0 spamscore=0 mlxscore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402210159 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240221_122357_834093_4F01C17D X-CRM114-Status: GOOD ( 25.15 ) X-BeenThere: kexec@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "kexec" Errors-To: kexec-bounces+kexec=archiver.kernel.org@lists.infradead.org On Wed, 2024-02-14 at 07:38 -0800, Tushar Sugandhi wrote: > Currently, the mechanism to map and unmap segments to the kimage > structure is not available to the subsystems outside of kexec. This > functionality is needed when IMA is allocating the memory segments > during kexec 'load' operation. Implement functions to map and unmap > segments to kimage. > > Implement kimage_map_segment() to enable mapping of IMA buffer source > pages to the kimage structure post kexec 'load'. This function, > accepting a kimage pointer, an address, and a size, will gather the > source pages within the specified address range, create an array of page > pointers, and map these to a contiguous virtual address range. The > function returns the start of this range if successful, or NULL if > unsuccessful. > > Implement kimage_unmap_segment() for unmapping segments > using vunmap(). Relocate 'for_each_kimage_entry()' macro from > kexec_core.c to kexec.h for broader accessibility. > > Signed-off-by: Tushar Sugandhi > --- > include/linux/kexec.h | 13 ++++++++++ > kernel/kexec_core.c | 59 +++++++++++++++++++++++++++++++++++++++---- > 2 files changed, 67 insertions(+), 5 deletions(-) > > diff --git a/include/linux/kexec.h b/include/linux/kexec.h > index 400cb6c02176..3145447eb77a 100644 > --- a/include/linux/kexec.h > +++ b/include/linux/kexec.h > @@ -486,6 +486,11 @@ static inline void arch_kexec_pre_free_pages(void *vaddr, > unsigned int pages) { > static inline void arch_crash_handle_hotplug_event(struct kimage *image) { } > #endif > > +#define for_each_kimage_entry(image, ptr, entry) \ > + for (ptr = &image->head; (entry = *ptr) && !(entry & IND_DONE); \ > + ptr = (entry & IND_INDIRECTION) ? \ > + boot_phys_to_virt((entry & PAGE_MASK)) : ptr + 1) > + I don't see a reason for moving this macro. Mimi _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec