linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu/arm-smmu-v3: fixed check process for disable_bypass module parameter
@ 2022-08-02 23:42 Shuuichirou Ishii
  2022-08-03  9:25 ` Robin Murphy
  0 siblings, 1 reply; 4+ messages in thread
From: Shuuichirou Ishii @ 2022-08-02 23:42 UTC (permalink / raw)
  To: will, robin.murphy, joro, thunder.leizhen, jgg, tglx,
	chenxiang66, christophe.jaillet, john.garry, baolu.lu,
	linux-arm-kernel, iommu, linux-kernel
  Cc: ishii.shuuichir

The current process does not enable the bypass setting regardless of
the value of the disable_bypass module parameter when ACPI is enabled,
so the value of the disable_bypass module parameter has been corrected
so that it is handled correctly.

Signed-off-by: Shuuichirou Ishii <ishii.shuuichir@fujitsu.com>
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index 88817a3376ef..256d7b2a83a7 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -3396,7 +3396,7 @@ static int arm_smmu_device_reset(struct arm_smmu_device *smmu, bool bypass)
 		enables &= ~(CR0_EVTQEN | CR0_PRIQEN);
 
 	/* Enable the SMMU interface, or ensure bypass */
-	if (!bypass || disable_bypass) {
+	if (!bypass && disable_bypass) {
 		enables |= CR0_SMMUEN;
 	} else {
 		ret = arm_smmu_update_gbpa(smmu, 0, GBPA_ABORT);
-- 
2.27.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] iommu/arm-smmu-v3: fixed check process for disable_bypass module parameter
  2022-08-02 23:42 [PATCH] iommu/arm-smmu-v3: fixed check process for disable_bypass module parameter Shuuichirou Ishii
@ 2022-08-03  9:25 ` Robin Murphy
  2022-08-03 12:45   ` ishii.shuuichir
  0 siblings, 1 reply; 4+ messages in thread
From: Robin Murphy @ 2022-08-03  9:25 UTC (permalink / raw)
  To: Shuuichirou Ishii, will, joro, thunder.leizhen, jgg, tglx,
	chenxiang66, christophe.jaillet, john.garry, baolu.lu,
	linux-arm-kernel, iommu, linux-kernel

On 2022-08-03 00:42, Shuuichirou Ishii wrote:
> The current process does not enable the bypass setting regardless of
> the value of the disable_bypass module parameter when ACPI is enabled,
> so the value of the disable_bypass module parameter has been corrected
> so that it is handled correctly.
> 
> Signed-off-by: Shuuichirou Ishii <ishii.shuuichir@fujitsu.com>
> ---
>   drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> index 88817a3376ef..256d7b2a83a7 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -3396,7 +3396,7 @@ static int arm_smmu_device_reset(struct arm_smmu_device *smmu, bool bypass)
>   		enables &= ~(CR0_EVTQEN | CR0_PRIQEN);
>   
>   	/* Enable the SMMU interface, or ensure bypass */
> -	if (!bypass || disable_bypass) {
> +	if (!bypass && disable_bypass) {

This change looks obviously wrong - if bypass is false here then we 
definitely want to enable the SMMU, so disable_bypass is irrelevant. It 
shouldn't even be possible to get here with bypass==true under ACPI, 
since arm_smmu_device_acpi_probe() cannot fail :/

Robin.

>   		enables |= CR0_SMMUEN;
>   	} else {
>   		ret = arm_smmu_update_gbpa(smmu, 0, GBPA_ABORT);

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] iommu/arm-smmu-v3: fixed check process for disable_bypass module parameter
  2022-08-03  9:25 ` Robin Murphy
@ 2022-08-03 12:45   ` ishii.shuuichir
  2022-08-03 12:54     ` Robin Murphy
  0 siblings, 1 reply; 4+ messages in thread
From: ishii.shuuichir @ 2022-08-03 12:45 UTC (permalink / raw)
  To: 'Robin Murphy',
	will, joro, thunder.leizhen, jgg, tglx, chenxiang66,
	christophe.jaillet, john.garry, baolu.lu, linux-arm-kernel,
	iommu, linux-kernel
  Cc: ishii.shuuichir

Hi, Robin,
Thank you for your comments.

> >   	/* Enable the SMMU interface, or ensure bypass */
> > -	if (!bypass || disable_bypass) {
> > +	if (!bypass && disable_bypass) {
> 
> This change looks obviously wrong - if bypass is false here then we definitely
> want to enable the SMMU, so disable_bypass is irrelevant. It shouldn't even be
> possible to get here with bypass==true under ACPI, since
> arm_smmu_device_acpi_probe() cannot fail :/

Sorry, my understanding of the meaning of the disable_bypass module parameter 
and the process of setting GBPA_ABORT was insufficient.

I misunderstood that the disable_bypass module parameter is used to simply 
bypass (disable) SMMU (SMMU_CR0.SMMUEN == 0 and SMMU_GBPA.ABORT == 0).
Forget about the fixes in this patch.

Although our understanding was lacking, 
we thought it would be a good idea to have a module parameter that simply disables SMMU,
so we were considering a fix.

Best regards, 
Shuuichirou.

> -----Original Message-----
> From: Robin Murphy <robin.murphy@arm.com>
> Sent: Wednesday, August 3, 2022 6:26 PM
> To: Ishii, Shuuichirou/石井 周一郎 <ishii.shuuichir@fujitsu.com>;
> will@kernel.org; joro@8bytes.org; thunder.leizhen@huawei.com; jgg@ziepe.ca;
> tglx@linutronix.de; chenxiang66@hisilicon.com; christophe.jaillet@wanadoo.fr;
> john.garry@huawei.com; baolu.lu@linux.intel.com;
> linux-arm-kernel@lists.infradead.org; iommu@lists.linux.dev;
> linux-kernel@vger.kernel.org
> Subject: Re: [PATCH] iommu/arm-smmu-v3: fixed check process for
> disable_bypass module parameter
> 
> On 2022-08-03 00:42, Shuuichirou Ishii wrote:
> > The current process does not enable the bypass setting regardless of
> > the value of the disable_bypass module parameter when ACPI is enabled,
> > so the value of the disable_bypass module parameter has been corrected
> > so that it is handled correctly.
> >
> > Signed-off-by: Shuuichirou Ishii <ishii.shuuichir@fujitsu.com>
> > ---
> >   drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > index 88817a3376ef..256d7b2a83a7 100644
> > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > @@ -3396,7 +3396,7 @@ static int arm_smmu_device_reset(struct
> arm_smmu_device *smmu, bool bypass)
> >   		enables &= ~(CR0_EVTQEN | CR0_PRIQEN);
> >
> >   	/* Enable the SMMU interface, or ensure bypass */
> > -	if (!bypass || disable_bypass) {
> > +	if (!bypass && disable_bypass) {
> 
> This change looks obviously wrong - if bypass is false here then we definitely
> want to enable the SMMU, so disable_bypass is irrelevant. It shouldn't even be
> possible to get here with bypass==true under ACPI, since
> arm_smmu_device_acpi_probe() cannot fail :/
> Robin.
> 
> >   		enables |= CR0_SMMUEN;
> >   	} else {
> >   		ret = arm_smmu_update_gbpa(smmu, 0, GBPA_ABORT);
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iommu/arm-smmu-v3: fixed check process for disable_bypass module parameter
  2022-08-03 12:45   ` ishii.shuuichir
@ 2022-08-03 12:54     ` Robin Murphy
  0 siblings, 0 replies; 4+ messages in thread
From: Robin Murphy @ 2022-08-03 12:54 UTC (permalink / raw)
  To: ishii.shuuichir, will, joro, thunder.leizhen, jgg, tglx,
	chenxiang66, christophe.jaillet, john.garry, baolu.lu,
	linux-arm-kernel, iommu, linux-kernel

On 2022-08-03 13:45, ishii.shuuichir@fujitsu.com wrote:
> Hi, Robin,
> Thank you for your comments.
> 
>>>    	/* Enable the SMMU interface, or ensure bypass */
>>> -	if (!bypass || disable_bypass) {
>>> +	if (!bypass && disable_bypass) {
>>
>> This change looks obviously wrong - if bypass is false here then we definitely
>> want to enable the SMMU, so disable_bypass is irrelevant. It shouldn't even be
>> possible to get here with bypass==true under ACPI, since
>> arm_smmu_device_acpi_probe() cannot fail :/
> 
> Sorry, my understanding of the meaning of the disable_bypass module parameter
> and the process of setting GBPA_ABORT was insufficient.
> 
> I misunderstood that the disable_bypass module parameter is used to simply
> bypass (disable) SMMU (SMMU_CR0.SMMUEN == 0 and SMMU_GBPA.ABORT == 0).
> Forget about the fixes in this patch.
> 
> Although our understanding was lacking,
> we thought it would be a good idea to have a module parameter that simply disables SMMU,
> so we were considering a fix.

Right, disable_bypass is a security/robustness feature for when the 
driver *is* in use. If for some reason you want to disable the SMMU 
drivers completely, they are regular driver model drivers, so just don't 
load the module in the first place (or use initcall_blacklist if it's 
built-in).

Thanks,
Robin.

> 
> Best regards,
> Shuuichirou.
> 
>> -----Original Message-----
>> From: Robin Murphy <robin.murphy@arm.com>
>> Sent: Wednesday, August 3, 2022 6:26 PM
>> To: Ishii, Shuuichirou/石井 周一郎 <ishii.shuuichir@fujitsu.com>;
>> will@kernel.org; joro@8bytes.org; thunder.leizhen@huawei.com; jgg@ziepe.ca;
>> tglx@linutronix.de; chenxiang66@hisilicon.com; christophe.jaillet@wanadoo.fr;
>> john.garry@huawei.com; baolu.lu@linux.intel.com;
>> linux-arm-kernel@lists.infradead.org; iommu@lists.linux.dev;
>> linux-kernel@vger.kernel.org
>> Subject: Re: [PATCH] iommu/arm-smmu-v3: fixed check process for
>> disable_bypass module parameter
>>
>> On 2022-08-03 00:42, Shuuichirou Ishii wrote:
>>> The current process does not enable the bypass setting regardless of
>>> the value of the disable_bypass module parameter when ACPI is enabled,
>>> so the value of the disable_bypass module parameter has been corrected
>>> so that it is handled correctly.
>>>
>>> Signed-off-by: Shuuichirou Ishii <ishii.shuuichir@fujitsu.com>
>>> ---
>>>    drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 +-
>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
>>> b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
>>> index 88817a3376ef..256d7b2a83a7 100644
>>> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
>>> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
>>> @@ -3396,7 +3396,7 @@ static int arm_smmu_device_reset(struct
>> arm_smmu_device *smmu, bool bypass)
>>>    		enables &= ~(CR0_EVTQEN | CR0_PRIQEN);
>>>
>>>    	/* Enable the SMMU interface, or ensure bypass */
>>> -	if (!bypass || disable_bypass) {
>>> +	if (!bypass && disable_bypass) {
>>
>> This change looks obviously wrong - if bypass is false here then we definitely
>> want to enable the SMMU, so disable_bypass is irrelevant. It shouldn't even be
>> possible to get here with bypass==true under ACPI, since
>> arm_smmu_device_acpi_probe() cannot fail :/
>> Robin.
>>
>>>    		enables |= CR0_SMMUEN;
>>>    	} else {
>>>    		ret = arm_smmu_update_gbpa(smmu, 0, GBPA_ABORT);

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-08-03 12:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-02 23:42 [PATCH] iommu/arm-smmu-v3: fixed check process for disable_bypass module parameter Shuuichirou Ishii
2022-08-03  9:25 ` Robin Murphy
2022-08-03 12:45   ` ishii.shuuichir
2022-08-03 12:54     ` Robin Murphy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).