lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1969aa1a-e092-4a48-b4a0-9a50ec2ef3b6@amd.com>
Date: Wed, 5 Feb 2025 15:16:58 +0530
From: Vasant Hegde <vasant.hegde@....com>
To: Sean Christopherson <seanjc@...gle.com>,
 Ashish Kalra <Ashish.Kalra@....com>
Cc: pbonzini@...hat.com, tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
 dave.hansen@...ux.intel.com, x86@...nel.org, hpa@...or.com,
 thomas.lendacky@....com, john.allen@....com, herbert@...dor.apana.org.au,
 davem@...emloft.net, joro@...tes.org, suravee.suthikulpanit@....com,
 will@...nel.org, robin.murphy@....com, michael.roth@....com,
 dionnaglaze@...gle.com, nikunj@....com, ardb@...nel.org,
 kevinloughlin@...gle.com, Neeraj.Upadhyay@....com, kvm@...r.kernel.org,
 linux-kernel@...r.kernel.org, linux-crypto@...r.kernel.org,
 linux-coco@...ts.linux.dev, iommu@...ts.linux.dev
Subject: Re: [PATCH v2 4/4] iommu/amd: Enable Host SNP support after enabling
 IOMMU SNP support

Hi ,

On 1/31/2025 7:18 AM, Sean Christopherson wrote:
> On Fri, Jan 31, 2025, Ashish Kalra wrote:
>> From: Sean Christopherson <seanjc@...gle.com>
>>
>> This patch fixes the current SNP host enabling code and effectively SNP
>   ^^^^^^^^^^
>> ---
>>  drivers/iommu/amd/init.c | 18 ++++++++++++++----
>>  1 file changed, 14 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
>> index c5cd92edada0..ee887aa4442f 100644
>> --- a/drivers/iommu/amd/init.c
>> +++ b/drivers/iommu/amd/init.c
>> @@ -3194,7 +3194,7 @@ static bool __init detect_ivrs(void)
>>  	return true;
>>  }
>>  
>> -static void iommu_snp_enable(void)
>> +static __init void iommu_snp_enable(void)
> 
> If you're feeling nitpicky, adding "__init" could be done in a separate patch.
> 
>>  {
>>  #ifdef CONFIG_KVM_AMD_SEV
>>  	if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP))
>> @@ -3219,6 +3219,11 @@ static void iommu_snp_enable(void)
>>  		goto disable_snp;
>>  	}
>>  
>> +	if (snp_rmptable_init()) {
>> +		pr_warn("SNP: RMP initialization failed, SNP cannot be supported.\n");
>> +		goto disable_snp;
>> +	}
>> +
>>  	pr_info("IOMMU SNP support enabled.\n");
>>  	return;
>>  
>> @@ -3426,18 +3431,23 @@ void __init amd_iommu_detect(void)
>>  	int ret;
>>  
>>  	if (no_iommu || (iommu_detected && !gart_iommu_aperture))
>> -		return;
>> +		goto disable_snp;
>>  
>>  	if (!amd_iommu_sme_check())
>> -		return;
>> +		goto disable_snp;
>>  
>>  	ret = iommu_go_to_state(IOMMU_IVRS_DETECTED);
>>  	if (ret)
>> -		return;
>> +		goto disable_snp;
> 
> This handles initial failure, but it won't handle the case where amd_iommu_prepare()
> fails, as the iommu_go_to_state() call from amd_iommu_enable() will get
> short-circuited.  I don't see any pleasant options.  Maybe this?
> 
> diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
> index c5cd92edada0..436e47f13f8f 100644
> --- a/drivers/iommu/amd/init.c
> +++ b/drivers/iommu/amd/init.c
> @@ -3318,6 +3318,8 @@ static int __init iommu_go_to_state(enum iommu_init_state state)
>                 ret = state_next();
>         }
>  
> +       if (ret && !amd_iommu_snp_en && cc_platform_has(CC_ATTR_HOST_SEV_SNP))

I think we should clear when `amd_iommu_snp_en` is true. May be below check is
enough?

	if (ret && amd_iommu_snp_en)


-Vasant


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ