Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1255823rwd; Tue, 16 May 2023 14:22:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ52f14rosejDSujsFy+y19nJU90skbhwKaUb6WGW91lEH8QociuLxT5WcxmgmWzYpuW/P5w X-Received: by 2002:a17:902:d2ca:b0:1ae:8fa:cd4c with SMTP id n10-20020a170902d2ca00b001ae08facd4cmr177300plc.7.1684272126090; Tue, 16 May 2023 14:22:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684272126; cv=none; d=google.com; s=arc-20160816; b=vwD9nlVWf4QnZ7xo/jBzaqt53vhiG59H8K9/aDb3Wq5q4Bi1NpNtLMZoQH3zEsT9Cy Ql9aofkzB99WL6kxT5GJsVde8VlQeMieBxlSD2iBrT1oCklVjXcpOeGvRwM0BCcJ0Vx+ Zd+rsIUxqvt6WHKX2Wo+XLg1WXap0SlEr7H5yQStab2XJkzdyv2/h5Rj6KSxZS77JR/S O9TSWbNMM109GyJ5bxmhW82Jr/gffqiicr83fKP8KJ51fnbKwFAx0VBGuv2tGPRYlzVe EGahlFdXT7i05vNcddLAiXVIHtXlX/LBFsWEQ4JmDddbtYTSa9X6QxwxgzMs8y66CS+Z 9cNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=SM660rXSVcN9oWH/JkR/2dCwZ/0PPpeUcJ1TWBxalsE=; b=yE+/N1BFaWA+HBbNOcxPV2j/ZpE4Ke0IrLQ0aGe6vpk/TLHIje3lNMB/UfQzN2affU W2xm6t2NnFkeQi7sVCdnNNMzyvLiU38MpOe1x14s2CvJhIrWKBUwpDd+u4xNyHDvKEAA 1hpXKeHXackNqNV0M02xMm5R6TB9LPkLAkn7dd/+LDneJux8VFOlt7q3QIDKfhVxl63q UVXoYXOPbjO1P746wLQF9BCqfTOQ0TDGpOoJp8BX9cOtxHlQhG1YmGEKXE6Awpjax//d qt/+YsIHdGpIQriv3iGV/B+9swmW9731nhboUD2i68KxTuiwOkoMnFPvZvzO8WgDvsrQ RW3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=qle+mMpD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y13-20020a170902b48d00b001aacffacf0bsi18604058plr.570.2023.05.16.14.21.53; Tue, 16 May 2023 14:22:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=qle+mMpD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229486AbjEPU73 (ORCPT + 99 others); Tue, 16 May 2023 16:59:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229566AbjEPU72 (ORCPT ); Tue, 16 May 2023 16:59:28 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87E3E59FB for ; Tue, 16 May 2023 13:59:27 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-64ab2a37812so8518013b3a.1 for ; Tue, 16 May 2023 13:59:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684270767; x=1686862767; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=SM660rXSVcN9oWH/JkR/2dCwZ/0PPpeUcJ1TWBxalsE=; b=qle+mMpD5mXwWmxOqRodWKMv/YfMpubGTtXVp2JF0NbGOFRBw2zJWfhe6D6GGITTi8 7v5SLXHMup7GpcU85gunOv2mT8flrnkSru94QJE7m1KlIkE4S0MaCNFefSdExv4DQYr9 O0PdGfKuo3yVUE0BuwIJDXWWhS915VGzAQj8npsSHOnGD7KNCdQRJbaCarXC4rmVfNsd NT0YJTuBegyDPWU7B9ImsVhR65V4cy7CvyZojlL7bvH7zgDk5WhVlxmVAC3wmZE9awOL o+exMTXltftfyIgXB8n8FTlh+zVLR9TxwJVXZcmXssRgFBjr8X/qfZWwjdyTy1bFV5/l oOag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684270767; x=1686862767; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SM660rXSVcN9oWH/JkR/2dCwZ/0PPpeUcJ1TWBxalsE=; b=G7I3sSz1Ux5LC4/oWd7fTn2a+NEH8WeteXOh+mWJKwm16IECjFoP0mlE0p8ijJLTqj BhFSLOAFuN7cTvITG/wD6rPeVcdCdDuXv/rO+8x2eeBaqBVhQykFiMdhMHjY+sea6Un1 X+Upx9ozBy/Nt4mSfyowi/Wik8DkNDrdW7J3p1v66CgXvO4RhklliQPkgrcjST1n9JvC 1ja7+iQX6AcSE5PUcA4rxc5J0AE4gmgXKkH6XrJ/ZFgILXNi9B9NOBXWdWn9Xk3MGFNM EkGHEhr7HDB92yFw42I2/v07z7/md/XI9Mun9TD9nt7CKlVguTbgMbSo6KpihHzhqfut RZsg== X-Gm-Message-State: AC+VfDyhYp20JuFXa6Hs3O9J6RYIdzWfLMLgB5uIm7EiehuLqkxDS4l2 0iYhrgQ60TNdzdMvNF8F+TLG5RwCtGyZ6jKztZho9Q== X-Received: by 2002:a05:6a20:3c9e:b0:104:873:c3be with SMTP id b30-20020a056a203c9e00b001040873c3bemr75149pzj.12.1684270766882; Tue, 16 May 2023 13:59:26 -0700 (PDT) MIME-Version: 1.0 References: <20230426203256.237116-1-pandoh@google.com> In-Reply-To: <20230426203256.237116-1-pandoh@google.com> From: Jon Pan-Doh Date: Tue, 16 May 2023 13:59:16 -0700 Message-ID: Subject: Re: [PATCH] iommu/amd: Fix domain flush size when syncing iotlb To: Joerg Roedel Cc: Suravee Suthikulpanit , Will Deacon , Robin Murphy , Nadav Amit , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Sudheer Dantuluri , Gary Zibrat , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Joerg, [Cc'ing stable@vger.kernel.org per Nadav's suggestion] This bug fix seems to have gotten the necessary reviews (AMD and previous commit author). Is it eligible to be applied? Thanks, Jon On Wed, Apr 26, 2023 at 1:32=E2=80=AFPM Jon Pan-Doh wro= te: > > When running on an AMD vIOMMU, we observed multiple invalidations (of > decreasing power of 2 aligned sizes) when unmapping a single page. > > Domain flush takes gather bounds (end-start) as size param. However, > gather->end is defined as the last inclusive address (start + size - 1). > This leads to an off by 1 error. > > With this patch, verified that 1 invalidation occurs when unmapping a > single page. > > Fixes: a270be1b3fdf ("iommu/amd: Use only natural aligned flushes in a VM= ") > Signed-off-by: Jon Pan-Doh > Tested-by: Sudheer Dantuluri > Suggested-by: Gary Zibrat > --- > drivers/iommu/amd/iommu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c > index 5a505ba5467e..da45b1ab042d 100644 > --- a/drivers/iommu/amd/iommu.c > +++ b/drivers/iommu/amd/iommu.c > @@ -2378,7 +2378,7 @@ static void amd_iommu_iotlb_sync(struct iommu_domai= n *domain, > unsigned long flags; > > spin_lock_irqsave(&dom->lock, flags); > - domain_flush_pages(dom, gather->start, gather->end - gather->star= t, 1); > + domain_flush_pages(dom, gather->start, gather->end - gather->star= t + 1, 1); > amd_iommu_domain_flush_complete(dom); > spin_unlock_irqrestore(&dom->lock, flags); > } > -- > 2.40.0.634.g4ca3ef3211-goog >