Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1201699ybt; Wed, 24 Jun 2020 23:40:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSJLpAgGOGdFZt+vBaZYz8gDlYSWIiy53X4OWIS+HLvB03EIkMNJmwtTXxHoEYvprFBpfU X-Received: by 2002:a17:906:7208:: with SMTP id m8mr29410667ejk.544.1593067237577; Wed, 24 Jun 2020 23:40:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593067237; cv=none; d=google.com; s=arc-20160816; b=AD2TMMLZ4eb4CuhJLAaQtzP8QdosbaQo3s/SyYOA7nhxMwE06kVWdmiKnRuGzUsdki AHPYrsQP0/YtYi9cHluXVFAT2PpyYOHhpzTZ4frd49W1Dkpmxmd8hGzsPKqXsLYTCdWw Ku2uXTfq6tzna+1tt0TThIXsUT05xtBt91Hcv3isKFS2+IxwEvW6pbclA3VLjnBpjlE0 kcMcQbsX9yrV8CwxNF5GxDsndhHAhmB78/XIBFgNtci0+KixgrqUeYXlcpyP1fEwo/1D pTuBrnTyEPnquTsOtm+XK4HUMHh2dk3+wTpAc4d5XVhUP1j+/0CIv7X7S5m5cv744B9g Qgzw== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=F3JPZx/ue2XMF/zWbDqbKJkfCJyISi4Zv4UmfRkZztQ=; b=Mk/MST1z1FNpjFrVPXt+yEN1iquVSJDiR5DzQtdbRZKr5hy3w3IDg4HnUBLQ8hT7Z7 ZNuJRBTtTeYSjCFI4L6ONXln/52213obq3ZVUJhD2ssFYBD+7cwU60AEq9z/E1j3blMI ohHSaOOGUBFYgOrw3yGtcOfL0Fu1NC3fah8xm5/DN3N+yieR9RwXFGbTD2QVrPRzhbvt 7y8B0ttwhpA/iqlktXsoXtI+ucV+pZy8vXHMzYPVSBQ9hLPI1JI5R7ZM/nLY8BJpaWQr D6g3+LnrF+vAM91EqAwulgbqHXE+57lbYD8Tx/sDq7SgESwLWNNZk4ZEevP0Fn3w3mVl hhOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yZZ1VTEy; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l13si13870988ejx.63.2020.06.24.23.40.13; Wed, 24 Jun 2020 23:40:37 -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=@kernel.org header.s=default header.b=yZZ1VTEy; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389890AbgFYGTQ (ORCPT + 99 others); Thu, 25 Jun 2020 02:19:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:54426 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389663AbgFYGTQ (ORCPT ); Thu, 25 Jun 2020 02:19:16 -0400 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 27763207E8; Thu, 25 Jun 2020 06:19:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593065955; bh=YbHGP11pHUX7giQDfbZQIvNPcOxAKEPuTaMFvWI1/mI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=yZZ1VTEyTafiT2YXaenbvvrLdDlo6nFFtivq2bXBWSj94Ii9nNCaabS/k/Xi9yKMm bXTyiyj2+7xgLAopMan2JLxV7MFY0KFkYmFCuPHveByBaBPRIp21WH48T3z1TWAOEh 3tV3DmTnBlzIa94uLY8ifxSrlGuF5vHpiTgjqs9s= Received: by mail-ej1-f51.google.com with SMTP id y10so4790948eje.1; Wed, 24 Jun 2020 23:19:15 -0700 (PDT) X-Gm-Message-State: AOAM530HmvOkzndY/AmQbmYPrPX80mZvn9l3airlkUBPYFAO8tqOlmqj Su36iogqXPK06uqcaujx9OTFjsk6S6ptyGN9sA== X-Received: by 2002:a17:906:856:: with SMTP id f22mr18224560ejd.245.1593065953692; Wed, 24 Jun 2020 23:19:13 -0700 (PDT) MIME-Version: 1.0 References: <1592559720-8482-1-git-send-email-neal.liu@mediatek.com> <1592559720-8482-3-git-send-email-neal.liu@mediatek.com> In-Reply-To: <1592559720-8482-3-git-send-email-neal.liu@mediatek.com> From: Chun-Kuang Hu Date: Thu, 25 Jun 2020 14:19:02 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 2/2] soc: mediatek: devapc: add devapc-mt6873 driver To: Neal Liu Cc: Rob Herring , Matthias Brugger , devicetree@vger.kernel.org, wsd_upstream , linux-kernel , "moderated list:ARM/Mediatek SoC support" , Linux ARM Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Neal: Neal Liu =E6=96=BC 2020=E5=B9=B46=E6=9C=8819=E6=97= =A5 =E9=80=B1=E4=BA=94 =E4=B8=8B=E5=8D=886:01=E5=AF=AB=E9=81=93=EF=BC=9A > > MT6873 bus frabric provides TrustZone security support and data > protection to prevent slaves from being accessed by unexpected > masters. > The security violations are logged and sent to the processor for > further analysis or countermeasures. > > Any occurrence of security violation would raise an interrupt, and > it will be handled by devapc-mt6873 driver. The violation > information is printed in order to find the murderer. > > Signed-off-by: Neal Liu > --- [snip] > + > +/* > + * sramrom_vio_handler - clean sramrom violation & print violation infor= mation > + * for debugging. > + */ > +static void sramrom_vio_handler(struct mtk_devapc_context *devapc_ctx) > +{ > + const struct mtk_sramrom_sec_vio_desc *sramrom_vios; > + struct mtk_devapc_vio_info *vio_info; > + struct arm_smccc_res res; > + size_t sramrom_vio_sta; > + int sramrom_vio; > + u32 rw; > + > + sramrom_vios =3D devapc_ctx->soc->sramrom_sec_vios; > + vio_info =3D devapc_ctx->soc->vio_info; > + > + arm_smccc_smc(MTK_SIP_KERNEL_CLR_SRAMROM_VIO, > + 0, 0, 0, 0, 0, 0, 0, &res); > + This irq handler call arm_smccc_smc() to get into TrustZone, why not let the whole irq handler in TrustZone? Regards, Chun-Kuang. > + sramrom_vio =3D res.a0; > + sramrom_vio_sta =3D res.a1; > + vio_info->vio_addr =3D res.a2; > + > + if (sramrom_vio =3D=3D SRAM_VIOLATION) > + pr_info(PFX "SRAM violation is triggered\n"); > + else if (sramrom_vio =3D=3D ROM_VIOLATION) > + pr_info(PFX "ROM violation is triggered\n"); > + else > + return; > + > + vio_info->master_id =3D (sramrom_vio_sta & sramrom_vios->vio_id_m= ask) > + >> sramrom_vios->vio_id_shift; > + vio_info->domain_id =3D (sramrom_vio_sta & sramrom_vios->vio_doma= in_mask) > + >> sramrom_vios->vio_domain_shift; > + rw =3D (sramrom_vio_sta & sramrom_vios->vio_rw_mask) >> > + sramrom_vios->vio_rw_shift; > + > + if (rw) > + vio_info->write =3D 1; > + else > + vio_info->read =3D 1; > + > + pr_info(PFX "%s: master_id:0x%x, domain_id:0x%x, rw:%s, vio_addr:= 0x%x\n", > + __func__, vio_info->master_id, vio_info->domain_id, > + rw ? "Write" : "Read", vio_info->vio_addr); > +} > +