[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v7 2/8] AMD/IOMMU: obtain IVHD type to use earlier


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 26 Aug 2021 14:33:08 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dEsPCMr11BnFmve3pFKcIxyR3ZldFnfLnTTlG6tJ9kk=; b=H0pwXJnQTXnrcSOtsgMJGjJXkFaEYVjg5/BoNoMJjnaDdnqNiyTnQ7q63Sz0r+N++TecqVgRSTehWTxnoFrSmFdT7GAgBa+fO9Q1APUCtn9ruerIUGrHFFvayFmQ+Dtq0yqJ1rElz2ohhfGL/RwKKCs/0tEr2Tqz7XlNIl6FYIPtB6BHhz81Mj4E46MWge1W4Cza6NdsERDiSGKszncC2Fjp0uncf9TaZ4AJPSBj7V9Xl7DQEwuhR9/igawzejjTCZav/A+WD2qzb5DVHfb/TcOCy3W21u2wVi5sUAaRR9w3DMqWHg0Azqq9iALEagovYGRgXGEIAP1GE+9krkwi0A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b0cn3t4Qs6dUk3s+4kB5CV12JTi66ZqUOFrb6/99BNyFxOjZ2wGuNRmDUcxpRvRhSXsKAiz8YoVbuLpRK2AwhvgAu3jIAE0+naLPkeLTkuDdWYijocqfxKM8N8k3GNfZmhysSkih9YZ9MOVk3tST3foTf+sk+w/BaFK8cJi85AGVLpFRQbkZH3qJ52qRandFA/o3COJAN21w2ruYxyEXtkXfTfHmipuJOmdJivJfDyWIlh9X2LRlZHHZTRdcvFYTn9n82IN0FRHpMkyMvfM7HNHziKW0DLRNl1pQS3ap7vQ7JiUs3UMAqYDeN2Pw5gxzwtHaBgIWc25Q4+8kIAkKEg==
  • Authentication-results: lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=suse.com;
  • Cc: Paul Durrant <paul@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 26 Aug 2021 12:33:16 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 26.08.2021 14:30, Andrew Cooper wrote:
> On 26/08/2021 08:23, Jan Beulich wrote:
>> Doing this in amd_iommu_prepare() is too late for it, in particular, to
>> be used in amd_iommu_detect_one_acpi(), as a subsequent change will want
>> to do. Moving it immediately ahead of amd_iommu_detect_acpi() is
>> (luckily) pretty simple, (pretty importantly) without breaking
>> amd_iommu_prepare()'s logic to prevent multiple processing.
>>
>> This involves moving table checksumming, as
>> amd_iommu_get_supported_ivhd_type() ->  get_supported_ivhd_type() will
>> now be invoked before amd_iommu_detect_acpi()  -> detect_iommu_acpi(). In
>> the course of dojng so stop open-coding acpi_tb_checksum(), seeing that
> 
> doing.
> 
>> --- a/xen/drivers/passthrough/amd/iommu_acpi.c
>> +++ b/xen/drivers/passthrough/amd/iommu_acpi.c
>> @@ -1150,20 +1152,7 @@ static int __init parse_ivrs_table(struc
>>  static int __init detect_iommu_acpi(struct acpi_table_header *table)
>>  {
>>      const struct acpi_ivrs_header *ivrs_block;
>> -    unsigned long i;
>>      unsigned long length = sizeof(struct acpi_table_ivrs);
>> -    u8 checksum, *raw_table;
>> -
>> -    /* validate checksum: sum of entire table == 0 */
>> -    checksum = 0;
>> -    raw_table = (u8 *)table;
>> -    for ( i = 0; i < table->length; i++ )
>> -        checksum += raw_table[i];
>> -    if ( checksum )
>> -    {
>> -        AMD_IOMMU_DEBUG("IVRS Error: Invalid Checksum %#x\n", checksum);
>> -        return -ENODEV;
>> -    }
>>  
>>      while ( table->length > (length + sizeof(*ivrs_block)) )
>>      {
>> @@ -1300,6 +1289,15 @@ get_supported_ivhd_type(struct acpi_tabl
>>  {
>>      size_t length = sizeof(struct acpi_table_ivrs);
>>      const struct acpi_ivrs_header *ivrs_block, *blk = NULL;
>> +    uint8_t checksum;
>> +
>> +    /* Validate checksum: Sum of entire table == 0. */
>> +    checksum = acpi_tb_checksum(ACPI_CAST_PTR(uint8_t, table), 
>> table->length);
>> +    if ( checksum )
>> +    {
>> +        AMD_IOMMU_DEBUG("IVRS Error: Invalid Checksum %#x\n", checksum);
> 
> I know you're just moving code, but this really needs to be a visible
> error.  It's "I'm turning off the IOMMU because the ACPI table is bad",
> which is about as serious as errors come.

I'll wait for us settling on patch 1 in this regard, and then follow
the same model here.

Jan




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.