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 X-Spam-Level: X-Spam-Status: No, score=-23.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7469C48BE6 for ; Fri, 11 Jun 2021 12:53:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D04F61042 for ; Fri, 11 Jun 2021 12:53:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231320AbhFKMz2 (ORCPT ); Fri, 11 Jun 2021 08:55:28 -0400 Received: from linux.microsoft.com ([13.77.154.182]:38666 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230233AbhFKMz1 (ORCPT ); Fri, 11 Jun 2021 08:55:27 -0400 Received: from sequoia (162-237-133-238.lightspeed.rcsntx.sbcglobal.net [162.237.133.238]) by linux.microsoft.com (Postfix) with ESMTPSA id 1E38A20B7178; Fri, 11 Jun 2021 05:53:28 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1E38A20B7178 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1623416009; bh=/cTsy8OGaEU/zCQc9L/8YrQzHcLViQBgidbXiYXlsFI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=g5OiGVB4m3mJcPxTG/Y/h4H/AIbequvqN042kTAxfzpbO/RnN+S9jdNuq7YXQf3SS cGp+pUj2THgiOumGn+Mf2YQ+kUp7ONyzL8mvLHKelSMNmh68wcE4E1CXBSupnVDbVZ SpvH/9rwBxHKKlNq5zxb+ZTeGAEod6vShaKQYbdU= Date: Fri, 11 Jun 2021 07:53:26 -0500 From: Tyler Hicks To: Jens Wiklander Cc: Allen Pais , Sumit Garg , Peter Huewe , Jarkko Sakkinen , Jason Gunthorpe , Vikas Gupta , Thirupathaiah Annapureddy , Pavel Tatashin , =?utf-8?B?UmFmYcWCIE1pxYJlY2tp?= , OP-TEE TrustedFirmware , linux-integrity , bcm-kernel-feedback-list@broadcom.com, linux-mips@vger.kernel.org, Linux Kernel Mailing List Subject: Re: [PATCH v4 3/8] optee: fix tee out of memory failure seen during kexec reboot Message-ID: <20210611125326.GQ4910@sequoia> References: <20210610210913.536081-1-tyhicks@linux.microsoft.com> <20210610210913.536081-4-tyhicks@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-06-11 11:11:33, Jens Wiklander wrote: > On Thu, Jun 10, 2021 at 11:09 PM Tyler Hicks > wrote: > > > > From: Allen Pais > > > > The following out of memory errors are seen on kexec reboot > > from the optee core. > > > > [ 0.368428] tee_bnxt_fw optee-clnt0: tee_shm_alloc failed > > [ 0.368461] tee_bnxt_fw: probe of optee-clnt0 failed with error -22 > > > > tee_shm_release() is not invoked on dma shm buffer. > > > > Implement .shutdown() method to handle the release of the buffers > > correctly. > > > > More info: > > https://github.com/OP-TEE/optee_os/issues/3637 > > > > Signed-off-by: Allen Pais > > Reviewed-by: Tyler Hicks > > Do we really need this considering the patch "optee: Refuse to load > the driver under the kdump kernel"? Yes. That patch fixes boot hangs when all of the OP-TEE threads were in the suspended state at the time of a kernel panic. The kexec into the kdump kernel after a panic is an "emergency" kexec that doesn't even call .shutdown hooks. There's no way for the OP-TEE driver to clean up after itself. This patch disables the shm cache (and unregisters the shm buffers) during a normal kexec from one perfectly working kernel into a new kernel. This is required because the new kernel will not be able to handle the virtual addresses that were cached under the old kernel. The new kernel has an entirely different memory layout and the old addresses point to unmapped memory or memory that's mapped but probably not a TEE shm. Tyler > > Jens >