From patchwork Mon Aug 26 07:16:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manoj Vishwanathan X-Patchwork-Id: 13777333 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 41A6EC54731 for ; Mon, 26 Aug 2024 07:23:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To:From: Subject:Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=glhE4wUH8upwh3h840zUvzyaLndPAI9WWeySK76KAe4=; b=LofHPzncUEN5pnGnWzZpGtJmKD kDa1PuS6JSS9i/7iqtP3/oYzdqoJSDKK3jBviaq+LpYp4EZTZQ1I64m9xtFxLngVY+yZlXl2ucIoe u+wJUXtu3kGGzYswkhrneJQgbJEkr4pfK8pyaO+zWe5kxniXZSsFgMJLCseg5FlwELLDoA6gpRfSN Ye8On3cncQsrzGvQihJSQm4ic/tf+Brr+Y8L4BlaIpn3qdwR+jHoY9x/oFiHZl4u3SDxC77gProLC Qf8J7YNnDPEoY9xMDmIO+qEmmdFW0wpHaACa+3ieXXJ5BIN27ifPpyzp7lPKh5ouBEWB9NgPEcLJJ /vF4kXww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siU4h-00000006FIz-2Rl9; Mon, 26 Aug 2024 07:23:39 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siTyN-00000006EJb-1f06 for linux-arm-kernel@lists.infradead.org; Mon, 26 Aug 2024 07:17:08 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6b0f068833bso72985537b3.0 for ; Mon, 26 Aug 2024 00:17:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1724656626; x=1725261426; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=glhE4wUH8upwh3h840zUvzyaLndPAI9WWeySK76KAe4=; b=QWOW1g+o/Cv/7yXfZd57f2DvpgsJws3RYVfp1Hznp19pGQgw+G1HuYSU72MjTzO8Dx hJCqP/eoRNNfNskjBuyYiWfVqP4tm+a0WXKBG/xCd6o3rYFwZLBOGmxMCfpmEo561TAK Gf+bkzWrENOcJPT37WGIwrQHSsY1uVOCarzP1IGLie1IYAl3LQUSgfNQDfRG8uufdRdt 2ZPK25rdIk5VYDrWvoHqBpYpIs0guZn+Er+H8oQ7BnpTIPEBrpvMtFwZe+uoYnhJYbnt AKLFcqogQMfXBJ6sjCNHv4NSfwkr71P4YUjRzi9HmHIys/loED5ee75Gx2gfGl2wbwct 284g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724656626; x=1725261426; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=glhE4wUH8upwh3h840zUvzyaLndPAI9WWeySK76KAe4=; b=Es7Ejf2KJHLjDWuOtKG/HJcm6V8Zr1dkzs8AwC0eHVymARYuCITkCarZbwxgOgf+O/ /F++lFHMccp3KYnwOhO2Ilq7lN8R/H6QWYrBRq8ovLWY/NatYtdjfsYsYD5ZfejWuQ0L BZTiQz6+WcX3Z+fgm57tmb8RmvmYc0TuroXY/soJ+qw6b3+IQVws1jPIPzmGrgigf79U 4OGmLo0LGvCrEuLkYXaevEIQ0zJOFKRy0Bb09993EqDjVcytMsTml0pNqTzqMmdtve+o i31urdTL4ZL4mrhfILGXkqF0o7Hya3wZLzl1NXbv9cWzI+x0vwEu5qqxFDE90ujWnBIp ++Fg== X-Forwarded-Encrypted: i=1; AJvYcCVp12bVe0kIX5VIolNwsN2y55SQhcIIBMBqDss/eE2EVfafGkC5cVhN/NprNnTZoCOAXEaTOzxGFJfI2+2WUcFU@lists.infradead.org X-Gm-Message-State: AOJu0Ywe1lrsBg3UZ0YJuNRQ6bhYVjn5A3CrWCQIJW0e4xK2KZqt71ra LvoxBVvVoUg31Yz5ZlQdoAFbaoaAvvbmUse03zPBRoKaeSTLZ1S6mH6YK59B3mrgfYZf5bDO//u 47JBXF0KgATx47gnSgA== X-Google-Smtp-Source: AGHT+IHNO2NOT8z5pjPX4FeBdIeAVLHmjqUYd3PJJUwIcYAFNDV3F2bzyhnKkfV2wlyMcU549dbh9KtZHmBsNHWt X-Received: from manojvishy.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:413f]) (user=manojvishy job=sendgmr) by 2002:a25:aa85:0:b0:e11:593b:b8e7 with SMTP id 3f1490d57ef6-e17a7a6905amr147799276.3.1724656626199; Mon, 26 Aug 2024 00:17:06 -0700 (PDT) Date: Mon, 26 Aug 2024 07:16:41 +0000 In-Reply-To: <20240826071641.2691374-1-manojvishy@google.com> Mime-Version: 1.0 References: <20240826071641.2691374-1-manojvishy@google.com> X-Mailer: git-send-email 2.46.0.295.g3b9ea8a38a-goog Message-ID: <20240826071641.2691374-5-manojvishy@google.com> Subject: [PATCH v1 4/4] vfio/type1: Add support for VFIO_DMA_MAP_FLAG_SYS_CACHE From: Manoj Vishwanathan To: Will Deacon , Robin Murphy , Joerg Roedel , Alex Williamson , linux-arm-kernel@lists.infradead.org Cc: kvm@vger.kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, David Dillow , Manoj Vishwanathan X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240826_001707_454299_AEDE8649 X-CRM114-Status: GOOD ( 13.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Introducing the VFIO_DMA_MAP_FLAG_SYS_CACHE flag to control whether mapped DMA regions are cached in the system cache. Signed-off-by: Manoj Vishwanathan --- drivers/vfio/vfio_iommu_type1.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 0960699e7554..c84bb6c8b12f 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -1562,7 +1562,8 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu, prot |= IOMMU_WRITE; if (map->flags & VFIO_DMA_MAP_FLAG_READ) prot |= IOMMU_READ; - + if (map->flags & VFIO_DMA_MAP_FLAG_SYS_CACHE) + prot |= IOMMU_SYS_CACHE; if ((prot && set_vaddr) || (!prot && !set_vaddr)) return -EINVAL; @@ -2815,7 +2816,7 @@ static int vfio_iommu_type1_map_dma(struct vfio_iommu *iommu, struct vfio_iommu_type1_dma_map map; unsigned long minsz; uint32_t mask = VFIO_DMA_MAP_FLAG_READ | VFIO_DMA_MAP_FLAG_WRITE | - VFIO_DMA_MAP_FLAG_VADDR; + VFIO_DMA_MAP_FLAG_SYS_CACHE | VFIO_DMA_MAP_FLAG_VADDR; minsz = offsetofend(struct vfio_iommu_type1_dma_map, size);