Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp474304pxy; Wed, 5 May 2021 06:47:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvBvM/Ibq9VJopvWTBxCczTRIYd6cfwtUdyWCK1KG8/TtQc2zhgEi6GnljK5T9nN5s/ryD X-Received: by 2002:a17:90b:300e:: with SMTP id hg14mr2499602pjb.149.1620222445112; Wed, 05 May 2021 06:47:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620222445; cv=none; d=google.com; s=arc-20160816; b=GRkNYQIajj51PbH8jodj0oHZcVRzhkG0nn3euajK7g5sFbWEPlsnFYeYoj1a8TZs8F qCOiRGrzsmLNBp/UxoWbxbQ+whmAyGzbLptbj30IuoY07mFZXJOskpoJ6c5sZHreBXxV sBEMf8ZSUL7panNaCQL65kNLpQuxjhVs8aDO1l6zQx36CZvyeNC1cM8WiyI40ywP6lJF ZfM2EQPOMfchgJf/8C54gii73MEXM+b/qlQFpa72Gjrw/ec/u8NwPB0evBDgrsBOc+5g OwfVs1xPnsapK5TVAQcR9e3AWYL1QtyuxWahoMeTpKtZnS0uDdsUO1yzRbfUvLys03Gk zf6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature:dkim-filter; bh=6WGq0zZgjhn3s0WdYzm2WfXRuIVMAkQFjwMZgX91eJI=; b=iDIIjRjqxqcPTS8ZozvpqWYY344yxSElaKuwHw9i9aFmYsBnMhZz9SPMJN8EC71zRJ bxkMRCWemBdRbH7bshUfQCKXWSxzdHpPuq5rfynkjLpzhqTwPkvyb86gzd+109E/i/XA niYTcctGCIF15b+qoPDN4tmnQu2gb1K2VSz/ZopUTQt4wetO2mbks5ay1IpSaaBJ0KrP zvX7zeRkReVQt3Z78ms9RwpodHrdukWMcdJkt/2BjCgAOBFiFGX1LGH22HAGnd+QoADn yAV2bAYSxpy9ve+ycGXXkLJCmVIlkPRjWi7mH0qGtLyaJC5c2r7nABXcIKBQOmdhyPeb JVNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=av3eNHzr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bx23si7512047pjb.6.2021.05.05.06.47.11; Wed, 05 May 2021 06:47:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=av3eNHzr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232967AbhEENq0 (ORCPT + 99 others); Wed, 5 May 2021 09:46:26 -0400 Received: from linux.microsoft.com ([13.77.154.182]:35356 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232101AbhEENq0 (ORCPT ); Wed, 5 May 2021 09:46:26 -0400 Received: from minint-m3g9p8n.europe.corp.microsoft.com (unknown [49.207.195.141]) by linux.microsoft.com (Postfix) with ESMTPSA id 65FEB20B7178; Wed, 5 May 2021 06:45:27 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 65FEB20B7178 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1620222329; bh=6WGq0zZgjhn3s0WdYzm2WfXRuIVMAkQFjwMZgX91eJI=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=av3eNHzrsMdu9Tzqxo4EFGsfxi5SmIEpx4dq+mvi1Ckor89fhXyVm43yGfHwPUP8J 2e6xDZ6PEBm4zTQy+QZD6baZHOx0xhyMbw/HnuQQZfLiFWMx2d7X+X086YYkqyj66J +BVGjhAQHwmEvtB9q/MG5bO6X6PTl86zK5FSl0hU= Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Subject: Re: [PATCH v2 1/2] optee: fix tee out of memory failure seen during kexec reboot From: Allen Pais In-Reply-To: Date: Wed, 5 May 2021 19:15:23 +0530 Cc: Allen Pais , zajec5@gmail.com, bcm-kernel-feedback-list@broadcom.com, Linux ARM , Linux Kernel Mailing List , OP-TEE TrustedFirmware Content-Transfer-Encoding: quoted-printable Message-Id: <409F60D9-F0FB-4B69-B64B-CC6B3704038E@linux.microsoft.com> References: <20210225090610.242623-1-allen.lkml@gmail.com> <20210225090610.242623-2-allen.lkml@gmail.com> <9a6c017c-d156-f939-f907-d6dfe83c41ac@linux.microsoft.com> To: Jens Wiklander X-Mailer: Apple Mail (2.3654.60.0.2.21) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jens,=20 >>>> [ 0.368428] tee_bnxt_fw optee-clnt0: tee_shm_alloc failed >>>> [ 0.368461] tee_bnxt_fw: probe of optee-clnt0 failed with error = -22 >>>>=20 >>>> tee_shm_release() is not invoked on dma shm buffer. >>>>=20 >>>> Implement .shutdown() method to handle the release of the buffers >>>> correctly. >>>>=20 >>>> More info: >>>> https://github.com/OP-TEE/optee_os/issues/3637 >>>>=20 >>>> Signed-off-by: Allen Pais >>>> --- >>>> drivers/tee/optee/core.c | 20 ++++++++++++++++++++ >>>> 1 file changed, 20 insertions(+) >>>=20 >>> This looks good to me. Do you have a practical way of testing this = on >>> QEMU for instance? >>>=20 >>=20 >> Jens, >>=20 >> I could not reproduce nor create a setup using QEMU, I could only >> do it on a real h/w. >>=20 >> I have extensively tested the fix and I don't see any issues. >=20 > I did a few test runs too, seems OK. I carried these changes and have not run into any issues with Kexec so = far. Last week, while trying out kdump, we ran into a crash(this is when the Kdump kernel reboots). $echo c > /proc/sysrq-trigger Leads to: [ 18.004831] Unable to handle kernel paging request at virtual address = ffff0008dcef6758 [ 18.013002] Mem abort info: [ 18.015885] ESR =3D 0x96000005 [ 18.019034] EC =3D 0x25: DABT (current EL), IL =3D 32 bits [ 18.024516] SET =3D 0, FnV =3D 0 [ 18.027667] EA =3D 0, S1PTW =3D 0 [ 18.030905] Data abort info: [ 18.033877] ISV =3D 0, ISS =3D 0x00000005 [ 18.037835] CM =3D 0, WnR =3D 0 [ 18.040896] swapper pgtable: 4k pages, 48-bit VAs, = pgdp=3D0000000970a78000 [ 18.047811] [ffff0008dcef6758] pgd=3D000000097fbf9003, = pud=3D0000000000000000 [ 18.054819] Internal error: Oops: 96000005 [#1] SMP [ 18.059850] Modules linked in: bnxt_en pcie_iproc_platform pcie_iproc = diagbe(O) [ 18.067395] CPU: 3 PID: 1 Comm: systemd-shutdow Tainted: G = O 5.4.83-microsoft-standard #1 [ 18.077174] Hardware name: Overlake (DT) [ 18.081219] pstate: 80400005 (Nzcv daif +PAN -UAO) [ 18.086170] pc : tee_shm_free+0x18/0x48 [ 18.090126] lr : optee_disable_shm_cache+0xa4/0xf0 [ 18.095066] sp : ffff80001005bb90 [ 18.098484] x29: ffff80001005bb90 x28: ffff000037e20000=20 [ 18.103962] x27: 0000000000000000 x26: ffff00003ed10490=20 [ 18.109440] x25: ffffca760e975f90 x24: 0000000000000000=20 [ 18.114918] x23: ffffca760ed79808 x22: ffff00003ec66e18=20 [ 18.120396] x21: ffff80001005bc08 x20: 00000000b200000a=20 [ 18.125874] x19: ffff0008dcef6700 x18: 0000000000000010=20 [ 18.131352] x17: 0000000000000000 x16: 0000000000000000=20 [ 18.136829] x15: ffffffffffffffff x14: ffffca760ed79808=20 [ 18.142307] x13: ffff80009005b897 x12: ffff80001005b89f=20 [ 18.147786] x11: ffffca760eda4000 x10: ffff80001005b820=20 [ 18.153264] x9 : 00000000ffffffd0 x8 : ffffca760e59b2c0=20 [ 18.158742] x7 : 0000000000000000 x6 : 0000000000000000=20 [ 18.164220] x5 : 0000000000000000 x4 : 0000000000000000=20 [ 18.169698] x3 : 0000000000000000 x2 : ffff0008dcef6700=20 [ 18.175175] x1 : 00000000ffff0008 x0 : ffffca760e59ca04=20 [ 18.180654] Call trace: [ 18.183176] tee_shm_free+0x18/0x48 [ 18.186773] optee_disable_shm_cache+0xa4/0xf0 [ 18.191356] optee_shutdown+0x20/0x30 [ 18.195135] platform_drv_shutdown+0x2c/0x38 [ 18.199538] device_shutdown+0x180/0x298 [ 18.203586] kernel_restart_prepare+0x44/0x50 [ 18.208078] kernel_restart+0x20/0x68 [ 18.211853] __do_sys_reboot+0x104/0x258 [ 18.215899] __arm64_sys_reboot+0x2c/0x38 [ 18.220035] el0_svc_handler+0x90/0x138 [ 18.223991] el0_svc+0x8/0x208 [ 18.227143] Code: f9000bf3 aa0003f3 aa1e03e0 d503201f (b9405a60)=20 [ 18.233435] ---[ end trace 835d756cd66aa959 ]--- [ 18.238621] Kernel panic - not syncing: Fatal exception [ 18.244014] Kernel Offset: 0x4a75fde00000 from 0xffff800010000000 [ 18.250299] PHYS_OFFSET: 0xffff99c680000000 [ 18.254613] CPU features: 0x0002,21806008 [ 18.258747] Memory Limit: none [ 18.262310] ---[ end Kernel panic - not syncing: Fatal exception ]=E2=80= =94 I see that before secure world returns OPTEE_SMC_RETURN_ENOTAVAIL(which Should disable and clear all the cache) we run into the crash trying to = free shm. Thoughts? Thanks.=