Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3223876rdg; Tue, 17 Oct 2023 08:07:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEFFIIrfnii3+ourQOZ4CcmRU/kWzyLxDsGxSi2H9bP7349DKw41WESo6BqZmlxKZq7s0n4 X-Received: by 2002:a05:6a21:7906:b0:16b:c20d:fcd1 with SMTP id bg6-20020a056a21790600b0016bc20dfcd1mr2455362pzc.21.1697555270033; Tue, 17 Oct 2023 08:07:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697555270; cv=none; d=google.com; s=arc-20160816; b=m9QgUfpIFmeyn9+Ddv+J+qqRyu8C7MT20BMLhwyAaueVfXjmeQMLW0FK5GRX+vaEAk qyhUv2tbLAj1raK34YK/RQfu3a+y15BOnlTsoCpdX7xASWVeeux6DaKiBsYZmSeTlBRD zx3qc+zD0XSHjx9NJpDoau0TZvxg+Sv9Avh5eNLtaS0rPxdA8+V1fwLYaOR+6wD2ZET9 jZKIxpKqD+EbyBsbOdAymy5UeixvABiNoqYr6rc4BFoPe16Ki6BmLlbz9VftTGFoDjvF f7duO8llaW4vTqsnTvJbM5E5ppUpJj0TJOQYKHVzKJaAdvr63mRfF7pOdfRpeaktG9Cv il1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=GkcETT//EFaL9Pze2jt5mEPkfaMAWnv0Qv1/ld7Gzfk=; fh=m3n0c4ky8C8c53OBHVX6CvnQdu/iCSf7AJ66IQCr8fY=; b=CPEKv27ZuWj1nuq6u5ypBy3iqBPVL80Wsly1wLf3lat2FKhQMFUPmTqPtAVKhoPG/I g7/q/D9KpMvU3E0tQeEbcxPyIpSlG6NmL6sUpET0TSKmVKQEmRVdj3RYg2JgFtT8SMmr uZATTcNh38gfl4sNZlzBz+90GtvqKo8wm2hbWWFxg3nwGPhac24WQPDKTtesQf6zsT2H Bvv2xHB2Z5LnX4cNFoUX3R8/N+cvURK7Z54ZofslYrCOf8Uy8y1nOPMaq17Rw71Dqka4 TP9TUDDLccbGN716LYQntb2cVbhVyw39SN9TbexsQ0tA0jxdYRxC5Tkz8LwMvVfY+5q5 Jm8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LRpzNVw2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id u23-20020a656717000000b00565eccbc52fsi2053307pgf.303.2023.10.17.08.07.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 08:07:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LRpzNVw2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 686B08026458; Tue, 17 Oct 2023 08:07:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344216AbjJQPHW (ORCPT + 99 others); Tue, 17 Oct 2023 11:07:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235075AbjJQPHI (ORCPT ); Tue, 17 Oct 2023 11:07:08 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADC994C04 for ; Tue, 17 Oct 2023 07:53:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697554335; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GkcETT//EFaL9Pze2jt5mEPkfaMAWnv0Qv1/ld7Gzfk=; b=LRpzNVw20A/Jor15CAeJ01hwIficb7X5OyhGddNM5E28X5gDL3YbhwQCO5Cgt2ENX8Elkk be3HajT3aOmKAQFQPiat4kyNuxle9nCGx37m1wwiVKLShpZAY9oNgC/8smKB2ejpA2Vp7Q N50bQLbMTgy5qMY4SDp0+16/lYoJpRo= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-544-xJOvuZDpMlyTLzI9SfdSkQ-1; Tue, 17 Oct 2023 10:52:04 -0400 X-MC-Unique: xJOvuZDpMlyTLzI9SfdSkQ-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-407da05ee50so4613275e9.0 for ; Tue, 17 Oct 2023 07:52:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697554323; x=1698159123; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=GkcETT//EFaL9Pze2jt5mEPkfaMAWnv0Qv1/ld7Gzfk=; b=rb0yqel0kP/kmhUadotuv1qRztS3SOicPBSKl8OxlrW8q8mPj3JKelabtswrZFp785 J3SZuerEEKcjbo/IsRpHt6qmCVq1PRa+mpDqlwEIfGVXhQf9PKfi4Fjt9AJ4tgbM3m+b mLwK6GdKtEvQ3sdqfJsSBTM3llqIM9ROJhRJpewuF7mGF+7cDuV79dy6ZREvMoRR2ed+ J+C5wL2SU6odRLiHYyhHI8Ht/mGQKltHbTpVGPpNAsO+HeqNUw+qRvHcWBRShGyLcoTm hWAXiaEgG4u9124HH14JrQSM1y36uNfcP70JwXSvi2VtNoTWTEzTpqoMdj2JtPzc3c7h Zr6w== X-Gm-Message-State: AOJu0Yx+GE4qvPs3SI+V9sSKheE9Iux4aKQYTS0Aui1nulqWmI0XVV4z lKAqf/mhPAbDSmKrMIYBiWp7e/1wpIHPv3jAthCLitGR3HjOketYcxEqh3wkzfUSIjFGfn9qo6R H8NMp1sT5p2JoZKmAkPbDfxOW X-Received: by 2002:a5d:4987:0:b0:32d:8f50:8553 with SMTP id r7-20020a5d4987000000b0032d8f508553mr2129611wrq.55.1697554322934; Tue, 17 Oct 2023 07:52:02 -0700 (PDT) X-Received: by 2002:a5d:4987:0:b0:32d:8f50:8553 with SMTP id r7-20020a5d4987000000b0032d8f508553mr2129602wrq.55.1697554322647; Tue, 17 Oct 2023 07:52:02 -0700 (PDT) Received: from starship ([89.237.100.246]) by smtp.gmail.com with ESMTPSA id h4-20020adfe984000000b003143c9beeaesm1860384wrm.44.2023.10.17.07.52.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 07:52:02 -0700 (PDT) Message-ID: <97d106d28e4c3468912a478dba79ab2221109cbd.camel@redhat.com> Subject: Re: [PATCH] iommu/amd: Do not flush IRTE when only updating isRun and destination fields From: Maxim Levitsky To: Suravee Suthikulpanit , linux-kernel@vger.kernel.org, iommu@lists.linux.dev Cc: joro@8bytes.org, seanjc@google.com, vasant.hegde@amd.com, jon.grimm@amd.com, santosh.shukla@amd.com, joao.m.martins@oracle.com, alejandro.j.jimenez@oracle.com, boris.ostrovsky@oracle.com Date: Tue, 17 Oct 2023 17:51:59 +0300 In-Reply-To: <20231017144236.8287-1-suravee.suthikulpanit@amd.com> References: <20231017144236.8287-1-suravee.suthikulpanit@amd.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 17 Oct 2023 08:07:41 -0700 (PDT) У вт, 2023-10-17 у 09:42 -0500, Suravee Suthikulpanit пише: > According to the recent update in the AMD IOMMU spec [1], the IsRun and > Destination fields of the Interrupt Remapping Table Entry (IRTE) are not > cached by the IOMMU hardware. Is that true for all AMD hardware that supports AVIC? E.g Zen1/Zen2 hardware? Is there a chance that this will cause a similar errata to the is_running errata that Zen2 cpus have? > > Therefore, do not issue the INVALIDATE_INTERRUPT_TABLE command when > updating IRTE[IsRun] and IRTE[Destination] when IRTE[GuestMode]=1, which > should help improve IOMMU AVIC/x2AVIC performance. > > References: > [1] AMD IOMMU Spec Revision (Rev 3.08-PUB) > (Link: https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/specifications/48882_IOMMU.pdf) Looks like the link is broken. Best regards, Maxim Levitsky > > Cc: Joao Martins > Cc: Alejandro Jimenez > Signed-off-by: Suravee Suthikulpanit > --- > drivers/iommu/amd/iommu.c | 20 ++++++++++++++++---- > 1 file changed, 16 insertions(+), 4 deletions(-) > > diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c > index 089886485895..d63590563d3e 100644 > --- a/drivers/iommu/amd/iommu.c > +++ b/drivers/iommu/amd/iommu.c > @@ -2970,8 +2970,8 @@ static int alloc_irq_index(struct amd_iommu *iommu, u16 devid, int count, > return index; > } > > -static int modify_irte_ga(struct amd_iommu *iommu, u16 devid, int index, > - struct irte_ga *irte) > +static int __modify_irte_ga(struct amd_iommu *iommu, u16 devid, int index, > + struct irte_ga *irte) > { > struct irq_remap_table *table; > struct irte_ga *entry; > @@ -2998,6 +2998,18 @@ static int modify_irte_ga(struct amd_iommu *iommu, u16 devid, int index, > > raw_spin_unlock_irqrestore(&table->lock, flags); > > + return 0; > +} > + > +static int modify_irte_ga(struct amd_iommu *iommu, u16 devid, int index, > + struct irte_ga *irte) > +{ > + bool ret; > + > + ret = __modify_irte_ga(iommu, devid, index, irte); > + if (ret) > + return ret; > + > iommu_flush_irt_and_complete(iommu, devid); > > return 0; > @@ -3681,8 +3693,8 @@ int amd_iommu_update_ga(int cpu, bool is_run, void *data) > } > entry->lo.fields_vapic.is_run = is_run; > > - return modify_irte_ga(ir_data->iommu, ir_data->irq_2_irte.devid, > - ir_data->irq_2_irte.index, entry); > + return __modify_irte_ga(ir_data->iommu, ir_data->irq_2_irte.devid, > + ir_data->irq_2_irte.index, entry); > } > EXPORT_SYMBOL(amd_iommu_update_ga); > #endif