From patchwork Thu Oct 7 18:06:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khalid Elmously X-Patchwork-Id: 1537881 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=NVlP6QzL; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HQK68250Mz9t25 for ; Fri, 8 Oct 2021 05:07:10 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1mYXnC-0004Kb-Gs; Thu, 07 Oct 2021 18:06:54 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1mYXnA-0004K8-GJ for kernel-team@lists.ubuntu.com; Thu, 07 Oct 2021 18:06:52 +0000 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 5B4FB3FFFC for ; Thu, 7 Oct 2021 18:06:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1633630012; bh=IIS58xHUX8fjtBYzcEnFrrDHRcsryBcVo0kbnW8Mevo=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=NVlP6QzLfNrG1MoX7XWuCphfgTG6P4d7zwssOXLs/mG49087f70ZOtbmkGd6cQX4j CqhzPtsOR8kQmr/1LyL0huMO5Ya+nuw/s4olSQR6TkxnMRHbIs8SjE+VKrXKxMFpng rEyVNs514jpMIL0NFGmfoxkzdhflIphpQyDhcyuA2X42ZlRiYFs3TkWcHg+M+My2tG iwjLJzj4/i3q9/gwZ4uPmOkcvrjflM/idv0n67hClk37bIaR7kkJ4GAyxsOO59SYYO I4UwlkZ0jLJrZKM5OvQaXQIhM3EyseXCVPzYLDtrsQ+wKdhl1EgTxAN1v7lARXQtaN WSyjw6mATYtEg== Received: by mail-qv1-f71.google.com with SMTP id e6-20020a0cb446000000b0037eeb9851dfso6413739qvf.17 for ; Thu, 07 Oct 2021 11:06:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IIS58xHUX8fjtBYzcEnFrrDHRcsryBcVo0kbnW8Mevo=; b=uwbJEv4vj7LqY/PdKFm1E+0rVeyB7wHPcz+e5sfz5X55cQwz+3OvtGKTIxbxdtgdbr coYeYnToyfquebfhjj4KJEj0ypi8AeoMoc9+FMQ24rDsaX11+RClzvK+cEMT1fueXMqF +cME4e+lhdeQ9Aao5ngnY1tnjvuhVouNJ+5ne0S4+aeNp8ZLTaIBgBjEcmz8W0O4j7/7 fXyH7wZVg0Qoz3t04bL/gjdffVdDvwxSIB4PG31HufEcCZY9VGVtXzdWTlV+cjNQH6Jl ugqONl0r68Fy6eVuvR/1VUWY+2cCfitNNaJ9Q2GV9mam1fFmEHSru3x30g0dmPHdQAPf kXnA== X-Gm-Message-State: AOAM5330WLpqiAL51QC4rzMbYyMoK22G610pV9SSTFYkmS6d8vZll1pb Jp6n2rKxRuK3C6DWPndOLUJgI5TEH6AKo99PmsBd07UeUOXN7OddGy8y3AYLhS8FymUBNnUlH6j CO18JQq+sqPqNlVIzGu4Fj+nFDQlBrZV9zLbfE599dw== X-Received: by 2002:a37:e17:: with SMTP id 23mr4574811qko.301.1633630011209; Thu, 07 Oct 2021 11:06:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwX/X5AqFpW5bGUJ5cUYRAiMeE30etH+GMYpdm4LcBw77ffh5Jvo1KYu8WPD+LVwfcw0T55rA== X-Received: by 2002:a37:e17:: with SMTP id 23mr4574785qko.301.1633630010942; Thu, 07 Oct 2021 11:06:50 -0700 (PDT) Received: from kbuntu2.fuzzbuzz.org (dhcp-24-53-240-12.cable.user.start.ca. [24.53.240.12]) by smtp.gmail.com with ESMTPSA id o22sm72382qkk.132.2021.10.07.11.06.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 11:06:50 -0700 (PDT) From: Khalid Elmously To: kernel-team@lists.ubuntu.com Subject: [SRU][PATCH v3 0/13][f/gcp] Fix nvme errors w/ swiotlb in confidential VMs Date: Thu, 7 Oct 2021 14:06:31 -0400 Message-Id: <20211007180644.9187-1-khalid.elmously@canonical.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/1943902 [Impact] Using nvme with swiotlb in confidential VMs can encounter hardware read/write errors. [Fix] The following upstream patches from v5.12 address this: 3d2d861eb03e nvme-pci: set min_align_mask 1f221a0d0dbf swiotlb: respect min_align_mask 16fc3cef33a0 swiotlb: don't modify orig_addr in swiotlb_tbl_sync_single 26a7e094783d swiotlb: refactor swiotlb_tbl_map_single ca10d0f8e530 swiotlb: clean up swiotlb_tbl_unmap_single c32a77fd1878 swiotlb: factor out a nr_slots helper c7fbeca757fe swiotlb: factor out an io_tlb_offset helper b5d7ccb7aac3 swiotlb: add a IO_TLB_SIZE define [Test] Using a confidential VM, with 'swiotlb=force' set on the kernel command line, and an additional nvme device attached: $ sudo mkfs.xfs -f /dev/nvme2n1 meta-data=/dev/nvme2n1 isize=512 agcount=4, agsize=131072 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=0, rmapbt=0, refl ink=0 data = bsize=4096 blocks=524288, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 mkfs.xfs: pwrite failed: Input/output error Note the input/output error The error no longer happens with the fixes applied. [Regression Potential] Potential regression in swiotlb could cause hardware read/write errors v2: Merged the NVME_CTRL_PAGE_[SIZE|SHIFT] definitions into last patch v3: Included further follow-up fixes. Bumyong Lee (1): swiotlb: manipulate orig_addr when tlb_addr has offset Christoph Hellwig (9): swiotlb: add a IO_TLB_SIZE define swiotlb: factor out an io_tlb_offset helper swiotlb: factor out a nr_slots helper swiotlb: clean up swiotlb_tbl_unmap_single swiotlb: refactor swiotlb_tbl_map_single swiotlb: don't modify orig_addr in swiotlb_tbl_sync_single swiotlb: respect min_align_mask swiotlb: remove the tbl_dma_addr argument to swiotlb_tbl_map_single swiotlb: move orig addr and size validation into swiotlb_bounce Claire Chang (1): swiotlb: Fix the type of index Jianxiong Gao (2): driver core: add a min_align_mask field to struct device_dma_parameters nvme-pci: set min_align_mask drivers/iommu/intel-iommu.c | 1 - drivers/nvme/host/pci.c | 9 ++ drivers/xen/swiotlb-xen.c | 3 +- include/linux/device.h | 1 + include/linux/dma-mapping.h | 16 ++ include/linux/swiotlb.h | 11 +- kernel/dma/swiotlb.c | 306 ++++++++++++++++++++---------------- 7 files changed, 199 insertions(+), 148 deletions(-) Acked-by: Kleber Sacilotto de Souza