From patchwork Mon Aug 26 07:16:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manoj Vishwanathan X-Patchwork-Id: 13777332 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 1A9CAC5472D for ; Mon, 26 Aug 2024 07:23:48 +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=QIcgUoBTp9GuGTx+59sM7fDXSn2WoTkdtpOjFEdC9AM=; b=B5g+VD3sJF9sTgN0gxlyqrefoc fsdq28gDWSg4mWphyZ3sqzRRn8mHOq0v3qCxfcfCtkY00ZarsE+mOKIkU5I1EPpAVVMnWrjic438l go5a4qX3JzuuF9iAqBXKeP6/dRhrEuTwES0JkTSFh2gYudzl535ndyXLLCEYNpfEcpED83wbgfk5M Vaoir2GS2UInmclvdJmORjVqIUab7rU+b/Wr0ITJFGd6Gb62d/0EyAbQGVMz22ACzxJwiyhHF5r6I Ae4bUl6hARr1p1e42jFFmmbgHNSmcX2OZF6cYiiNYmr83A9EvVAtvW1OmZcM7RBXdW9PNlzph69b9 pxv2/Y3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siU4c-00000006FEg-2iuo; Mon, 26 Aug 2024 07:23:34 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siTyB-00000006EFy-46BI for linux-arm-kernel@lists.infradead.org; Mon, 26 Aug 2024 07:16:57 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e03b3f48c65so7263342276.0 for ; Mon, 26 Aug 2024 00:16:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1724656614; x=1725261414; 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=QIcgUoBTp9GuGTx+59sM7fDXSn2WoTkdtpOjFEdC9AM=; b=YyrwRpdU1JiiHFCamBYy5Hqdm0y1X9K1y4HEEZWZGNoYjlwMY/g4nFvHy//g76i/ow r1caiGR1ShPcHLFOHB9Iap4ZyIWCqIaa2KgFPVxhVZx6F6ABgCH208m6dsyiqBTXDX2H PTTYhnysNbzdUz3mXsSnKe1maAV4PfVZDDY4P+y+jfdSX4wRY+SvHMphoVEkLmWt8Pwx O5qTTdcWBCLJsEbKTb1Nzx3CnfhIVORIDImbn/rq167bU11GxJvcFfS5gszdd+CwcikC TddfwxJ045iAUokzOpOc3jq1fVFOLf6G7i3eLUPqc4w7K6DSf11oYgEb8yzySksIinpu YOEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724656614; x=1725261414; 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=QIcgUoBTp9GuGTx+59sM7fDXSn2WoTkdtpOjFEdC9AM=; b=PZoHhQl2yex1qBUNmOv7G9LsVjz49zDzEVWGSsiWIhhvIewKTpAWlzMvtyZm+Kjkam Z4iXaASUhult9gbEnavZXFx2hVb8peTEaph5IevamImFB/CBRyZOStc2b3tos+JxdCNM YWx1YHHQER+lKVo4aZ70yfzWuBrq8PYizNb42dxufbcbseeEiYhlQDHkv/OYUrUTK6IN /f1m9JFVuLyuZu/wYhcxMHiCvK00fk6bGNhFk2hCCpuHhHPwDJtR/zKX9uqsG6eO8NGd TXNson7PTk3bLfbB7iYS1mtWspwM8DXVeS0r2rbhAGkGcxwGKpIBHaEreVKvUI4+3SNp 677g== X-Forwarded-Encrypted: i=1; AJvYcCUmMgauXMUpo0h0qZGVRDOYbqOqdoaL9Gifjq/Eft3e7sO0eHkeHjFzwdxkETGUjUZ9ZGECc6oIHtcuw6MS7doB@lists.infradead.org X-Gm-Message-State: AOJu0Yx+yWO5VBZS/4gI1rSwWFpo5QhRCeAi0oCZoEMEDrvG20BOkwQ4 57AiHZdB5ASSfIx/IWkcRXLvWh4NgAOTmMxeJqCTn0KVFh8gO88kbjn1+HjkWKI6xDGLU/S6n21 xd95A6U3jpMTh3Hbysw== X-Google-Smtp-Source: AGHT+IHrlol7Anpnd920uxfnTbedTgfOoLRdg3g5Rtafipisfy+CH2cN56NbbUf6MkXF303FuBbETzycPNKV+61W X-Received: from manojvishy.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:413f]) (user=manojvishy job=sendgmr) by 2002:a25:ad5d:0:b0:e16:50d2:3d36 with SMTP id 3f1490d57ef6-e17a86208demr247806276.7.1724656613663; Mon, 26 Aug 2024 00:16:53 -0700 (PDT) Date: Mon, 26 Aug 2024 07:16:38 +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-2-manojvishy@google.com> Subject: [PATCH v1 1/4] iommu: Add IOMMU_SYS_CACHE flag for system cache control 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_001656_033246_99A17D80 X-CRM114-Status: GOOD ( 10.35 ) 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 This flag indicates whether the associated page should be cached in the system's cache hierarchy. Signed-off-by: Manoj Vishwanathan --- include/linux/iommu.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 04cbdae0052e..ca895c83c24f 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -31,6 +31,12 @@ */ #define IOMMU_PRIV (1 << 5) +/* + * Flag to indicate whether the associated page should be cached in the + * system's cache hierarchy. + */ +#define IOMMU_SYS_CACHE (1 << 6) + struct iommu_ops; struct iommu_group; struct bus_type; From patchwork Mon Aug 26 07:16:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manoj Vishwanathan X-Patchwork-Id: 13777330 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 1B425C54731 for ; Mon, 26 Aug 2024 07:23:46 +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=BRShtYLZmJBPJSHqgx4PDt4rvJ58jLkk96vd1/jbIvg=; b=z+MdJbXhe8Zs6eUDlegb7lyRS9 u88EmFXbMagzGVZJ/BD4l94cWwzSLUCmKrnOXhd1QoZhnXqbTGzV7BxA1ylMVsw2dLD23tmA8Ih7u sjBo5RWnYpI1VLt8W/6oPSM4wyCDSjO5YzmsdY8MQsdAWdjF39hD1T+HpxndBw/lQgomNQxi+rW+Y D2V2meoiDPRxj8Q6qtpLiqfGrcKioBk9u94NuLZfNDZCWIdWRAeckm/MUs+JvyvDlKT/L2slv00/X c5X7Po1LLc9W3nJLCCw3fNkSi3CHUwoEmBgZokTG8giyldslNGgCl9PYUOvIVRrzcTm6BGWPX9JGg 96GWk/xg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siU4d-00000006FFN-31Wv; Mon, 26 Aug 2024 07:23:35 +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 1siTyH-00000006EI3-4BY7 for linux-arm-kernel@lists.infradead.org; Mon, 26 Aug 2024 07:17:03 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6b1adbdbec9so78512757b3.0 for ; Mon, 26 Aug 2024 00:17:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1724656620; x=1725261420; 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=BRShtYLZmJBPJSHqgx4PDt4rvJ58jLkk96vd1/jbIvg=; b=QSqUQihMtt0zdjwjdpSvsr+zCZrwtR/mYvv5k0wEmoBWzmkAwD/4hf5iRJEzQVGrx4 ZwSksXI1j5xMt4Zx8i/ymHErLUDR6WGkCcOk9fq7OPoegpX9nfYnlsVqxfu/vWUCBI6J vmQl5gbBCqwe9VPVWfEjIlFhSgI0q57NSYnDSUiWRAhEa/wJj8Di4FCxcfVTeUq2rTMi BUGhoPRh9YekhhDflwjT3q7UTsfwORMhNkxrBypwMqtMZ1exG/Md2imB64t38XJ+bc8P r8Xr3sQ8IaFPqUyAVR7uHhH0U/8i+qbp4drrlUPDnpYJmDdxdZZGiMts+AQ/MOr8qDf9 Qq7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724656620; x=1725261420; 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=BRShtYLZmJBPJSHqgx4PDt4rvJ58jLkk96vd1/jbIvg=; b=VJ1C83iwvod+l+UvkVOJ7Gqrno9m0Tys2/ItEpwB03tzK55jakdfg801cx6jmj0cO6 iyffczcy7WzovbPnuRd4cZOYQpP7zPHLA+NBpOYJP55nVx8Q8Nkv+BX4IzRaHbYyNzYc 8ziobm04RvBpuQ18NL2b5jiIysQaaSoZAmX78glfla+e81zIV4GjcJ2S7+QOrho4/GTD owcF1EP+xaWwsuvCow+W4GEZk/cWuOw4X3gcpOtxFz00apjchRXZj0mhXB1EIxLcaWqU k94sCrTvd7jr8a0dp3Wd11/fHJyj/TWcvKXShLZDS2rA6sgXK7YTTZz4hfzz6jn8m/Ge i4wQ== X-Forwarded-Encrypted: i=1; AJvYcCVUbjHoa7dtezunhzsUJt5E3hQGirfxXtaZAQtsiY7CTxP/W7GufEGCQt0paXQUmBxjbdnu5Mo3aHBX4LDK+UbH@lists.infradead.org X-Gm-Message-State: AOJu0YyNDW+FwcdpeF3iX+c4ggrM88dPIsdlYQQvh/HITgBcyhGACl5i U8RwM2KUMjAIt15NUoJhR9VMBgn6XKrnsoqvX2+8LvFBKl7cApExkLBs3v7SgUxK7Gs8xG102hd Qy0nqTxGeSv+fZBw0AQ== X-Google-Smtp-Source: AGHT+IFvc8OHSGEhjIEIYer2jfp9QrAbi6exBOTouXCSVWGbyUY3HkgdonvtEDMyxk52fnOPsWuReZ1tNXp20tcu X-Received: from manojvishy.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:413f]) (user=manojvishy job=sendgmr) by 2002:a05:690c:2b8c:b0:69a:536:afde with SMTP id 00721157ae682-6c627d07c73mr623137b3.5.1724656619604; Mon, 26 Aug 2024 00:16:59 -0700 (PDT) Date: Mon, 26 Aug 2024 07:16:39 +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-3-manojvishy@google.com> Subject: [PATCH v1 2/4] iommu/io-pgtable-arm: Force outer cache for page-level MAIR via user flag 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_001702_060571_D4483124 X-CRM114-Status: GOOD ( 10.86 ) 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 This change introduces a user-accessible flag that allows controlling the system-level outer cache behavior for mapped buffers. By setting this flag, the page-level MAIR attribute will be forced to use the outer cache, potentially improving performance for frequently accessed data. Signed-off-by: Manoj Vishwanathan --- drivers/iommu/io-pgtable-arm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index f5d9fd1f45bf..31dd6203db96 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -471,6 +471,9 @@ static arm_lpae_iopte arm_lpae_prot_to_pte(struct arm_lpae_io_pgtable *data, else if (prot & IOMMU_CACHE) pte |= (ARM_LPAE_MAIR_ATTR_IDX_CACHE << ARM_LPAE_PTE_ATTRINDX_SHIFT); + else if (prot & IOMMU_SYS_CACHE) + pte |= (ARM_LPAE_MAIR_ATTR_IDX_INC_OCACHE + << ARM_LPAE_PTE_ATTRINDX_SHIFT); } /* From patchwork Mon Aug 26 07:16:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manoj Vishwanathan X-Patchwork-Id: 13777334 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 1EDBFC5472F 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=UlAkpThGXQLvVPx+k8dqLCpxi8en9zSnxpsu3M8WXYc=; b=zQwFIVZOSTG6jurtmRG5L1cJYB Dv42BOIrBLYXTwlC+YdglyshR1UlnNOwdHbBlAw9HYR+Uew5U6E7iyYFnQmNzIpldfLx34yMvv/gd 7JW2Oh/VYyWu/ttWR0sGrEly5Z8D3Z9w+XEK7CI+bKeDTRsjoKQSBMeivpa/gZMtESmtfhqwi5366 A/12lncPOJFuPZHic6jeeGU8vlYVL+mPzN2TxWr1ah0Y4CNFJXX045zxAKz2/eHAENnST8AGOFLT0 rH/b9y2ff5rNTQNFIo0zN2syi8Am3hLPG3V5YyFxbC7HVRbolRferwLt+Eocz9Ij2HmFOqvyZaf1M dQsQm6+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siU4f-00000006FGv-1wER; Mon, 26 Aug 2024 07:23:37 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siTyK-00000006EIn-2J1C for linux-arm-kernel@lists.infradead.org; Mon, 26 Aug 2024 07:17:05 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-6b351a76beeso87164667b3.0 for ; Mon, 26 Aug 2024 00:17:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1724656623; x=1725261423; 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=UlAkpThGXQLvVPx+k8dqLCpxi8en9zSnxpsu3M8WXYc=; b=z7zNTiLSLlWmbKhs/+VA6QAyrl5vl+F4YZhX5nSgkjHM17iEzubQpctiLKBDhQxnF9 u1SgRqS29Qd95gCRYlBZ99d/sKhYEYrvnxa3KTjHljb4X5KKS+mO3yJroq5reoP8zMRS +JjONhd2TpQVgffZ1VtXsQm5SdK4+E8mRu3ja+6AoBxSazypImibzC/0vn0ZBneHxysO FUSsTJ7WUGzIlFu4ogZSxUccjEoo61gOP75TPXhPevpEHCbMXXdGkPTQ988/HL3Ttbep ZoIidGAobqUOuOqGuCoBdgbe5KHKVIhiT+EhUVJzoisvO2WFwkjfdY1YQjBeAvCkBWN8 rD7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724656623; x=1725261423; 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=UlAkpThGXQLvVPx+k8dqLCpxi8en9zSnxpsu3M8WXYc=; b=bJuspUYLZd0pdzr4pcYNijZs3IjPb0lG6hWFfAnoeVwaVsEy1u6WS2r8gBxwKLdhdH Uzw1EwHqB4aJ7uhdAX1wQKTa/Mgxmb3I2ATxEek5EaCpbZ8vXB9u6faphAdVfamXNHUo oTiqfVQCS9+PEaJPxkYHu+egkLUbrWtPujEx+B4h2NrE7SQXPmhoKEEHdsLosCae5iZ7 MiuJk0EHcFmfAhzvd8eUR7nhDBimYuNQN/vJ4O6kbCFWvPeTMm3mNKxu7hfbegRx84Hs o8+jA1/9fc/paYmkujIki19PzhOyTxHu/sLyv0RPoel8bznoMU5OHk1ttdsPM5WuRIAw zMJQ== X-Forwarded-Encrypted: i=1; AJvYcCVs4GonHDMbGbs5yiDYo/EpZrutvrPMS7D5PonQL/jW9OPZRPH/s6FOpmgdHl2uHlWx3re9hD5+oGYnrGv1MzV4@lists.infradead.org X-Gm-Message-State: AOJu0YxvBcsyES103TufMqVFZ8K8dZMnzwFXdstPHkCO49lSasRA1smq PiA+WtOVAxVzacDaf+mOT/816pLwsOGto3CLXksdljnI3TIyslkM8xFprj3pH9uPr1Nk/Q5zSzG eqb+hPJzgBvgPAULnHQ== X-Google-Smtp-Source: AGHT+IGTv9O5nWsMNvAuvREulYcA7bXvWQ9CujjRqJDianvCbgB7Y8UFv1A0WfQ112BR7wvtStav+ASLkpwyAOMW X-Received: from manojvishy.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:413f]) (user=manojvishy job=sendgmr) by 2002:a81:dc07:0:b0:691:41f5:7f3d with SMTP id 00721157ae682-6c627f0b1e1mr463277b3.4.1724656623018; Mon, 26 Aug 2024 00:17:03 -0700 (PDT) Date: Mon, 26 Aug 2024 07:16:40 +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-4-manojvishy@google.com> Subject: [PATCH v1 3/4] vfio: Add VFIO_DMA_MAP_FLAG_SYS_CACHE to control device access to system 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_001704_607701_DC204709 X-CRM114-Status: GOOD ( 10.98 ) 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 This new flag allows controlling whether a device buffers should be mapped to sys cache for mapped DMA regions. Signed-off-by: Manoj Vishwanathan --- include/uapi/linux/vfio.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h index 2b68e6cdf190..494611a046d3 100644 --- a/include/uapi/linux/vfio.h +++ b/include/uapi/linux/vfio.h @@ -1560,6 +1560,7 @@ struct vfio_iommu_type1_dma_map { #define VFIO_DMA_MAP_FLAG_READ (1 << 0) /* readable from device */ #define VFIO_DMA_MAP_FLAG_WRITE (1 << 1) /* writable from device */ #define VFIO_DMA_MAP_FLAG_VADDR (1 << 2) +#define VFIO_DMA_MAP_FLAG_SYS_CACHE (1 << 6) /* Sys Cache able from device */ __u64 vaddr; /* Process virtual address */ __u64 iova; /* IO virtual address */ __u64 size; /* Size of mapping (bytes) */ 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);