[PATCH v2 2/2] soc: mediatek: add mtk-devapc driver

Neal Liu neal.liu at mediatek.com
Wed Jul 15 23:42:30 EDT 2020


Hi Chun-Kuang,

On Thu, 2020-07-16 at 07:46 +0800, Chun-Kuang Hu wrote:
> HI, Neal:
> 
> Neal Liu <neal.liu at mediatek.com> 於 2020年7月9日 週四 下午5:13寫道:
> >
> > MediaTek bus fabric provides TrustZone security support and data
> > protection to prevent slaves from being accessed by unexpected
> > masters.
> > The security violation is 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 mtk-devapc driver. The violation
> > information is printed in order to find the murderer.
> >
> > Signed-off-by: Neal Liu <neal.liu at mediatek.com>
> > ---
> 
> [snip]
> 
> > +
> > +/*
> > + * mtk_devapc_dump_vio_dbg - shift & dump the violation debug information.
> > + */
> > +static bool mtk_devapc_dump_vio_dbg(struct mtk_devapc_context *devapc_ctx,
> > +                                   int slave_type, int *vio_idx)
> > +{
> > +       const struct mtk_device_info **device_info;
> > +       u32 shift_bit;
> > +       int i;
> > +
> > +       device_info = devapc_ctx->device_info;
> > +
> > +       for (i = 0; i < get_vio_slave_num(slave_type); i++) {
> > +               *vio_idx = device_info[slave_type][i].vio_index;
> > +
> > +               if (check_vio_mask(devapc_ctx, slave_type, *vio_idx))
> > +                       continue;
> 
> I guess if one vio_idx is masked, its status would never be true. If
> my guess is right, I think you could skip check_vio_mask() and
> directly check_vio_status().

No. Even if vio_idx is masked, vio_status will still raise when
violation is triggered.

> 
> > +
> > +               if (!check_vio_status(devapc_ctx, slave_type, *vio_idx))
> > +                       continue;
> > +
> > +               shift_bit = get_shift_group(devapc_ctx, slave_type, *vio_idx);
> > +
> > +               if (!sync_vio_dbg(devapc_ctx, slave_type, shift_bit))
> > +                       continue;
> > +
> > +               devapc_extract_vio_dbg(devapc_ctx, slave_type);
> > +
> > +               return true;
> 
> I think multiple vio_idx would violate at the same time, why just process one?

We process each vio_idx for each interrupt.
If there are multiple vio_idx is raised, it will trigger another
interrupt to handle it.

> 
> Regards,
> Chun-Kuang.
> 
> > +       }
> > +
> > +       return false;
> > +}



More information about the Linux-mediatek mailing list