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: 13777295 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DBE612DD8A for ; Mon, 26 Aug 2024 07:16:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724656616; cv=none; b=IYlQ23U9H7eMuQl+z4XG04yFKOqV7ARoQjwMPK74C0U83S2OWVvpFFfTXG6urh0IBRq1ow6vj+S4mcWaA5hsZaCxOpm3ZNdSKalMUpl/5UFPo+5TyAsA0ub2v2I+oHSEqsw42DZOFjjdPqgFEQKiAQnJTyYOHzXwxzbYQcucF6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724656616; c=relaxed/simple; bh=HP374hzQKt1PoMnLVLHbgO5xbnjTW90EAECCpEBd9MY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=NbTOzOqYdvqFAXxSNAZ1q0QrxnZB0lzSEDdEB9HwQkmM3V9ZrXdRJxfesvgc/t6YdNVFR6LuPlb5WMau5kWtfBrXhCbTd93CVn9CTVKF/K1J2bpntaai/K1gLkGnPmndrBl6Vmta83hKSA31lWthpM437AwBD4Wnw1k2l3Bk7Mo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--manojvishy.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=iTRiaFj9; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--manojvishy.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="iTRiaFj9" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e165fc5d94fso7084126276.2 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=vger.kernel.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=iTRiaFj9DVQv5vMxurVVHm9QF8PGaaxslhibr4dOqZgEmBXS0qd0Pe9NgxqPZoShKI oWTP6JOaplLGzEoKYlsl2wqKGg5SGAInS+L1cxLnGCkLekvS7AM5i8ERN8qNGLxP+DfV XO0MOKFo5ev3blh8TCW+gI6z9XVx0u0wRi1PECfkYidYjFlDoQnOAiMAT23Cy7PHZo4b +mKnAkb1jkwkXOq5Fa25/PTg1ZKlR/+AeCLv/hSoSft4BOf/gPtkOQ9YkFRhdsFCxFtB YqpHUHT9TtkmnVrH3Pc3GZamSNYa0EWAw5cEq13PO5DxFOzl1dvqQa3MRshFJuTsArOr ScDA== 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=chrL8Hr2QUctXmc4akKQSVPpSgqL5emZ93QooinjzIJJfi9nZOWLfPhd4wXzuK9Hu6 e3SmTJsB7w9mD4sIcG/2qd25LORccL6yV7h/CrKaSju12zW9m7uQNwp3y2vq70wEAIkb uz7PjQrRXq2olNOfGGKc5G75IgKX6kllhJp3Gc/kTQXKB94qWXUW0TbXZJvMn68a3XTZ QstkhA01g/xbo+xYlV1TXr0nseAcI8jU87OQpAMOtqNzrdwbpu4XEdW9FL2YsYXxlvD6 AmcrRN1B6wfJJRwQ+T6T/fmvBTPjXN+Q3RGmkd+SFdipAaHT6qRcFLtg4pky9GIvJVwC Tt3Q== X-Gm-Message-State: AOJu0YwXWeCuu6KG36kVj0BGmI9BYQwRKKwoEfdYoT2nw3LdKwUi73Q/ N20uucSEBS+ozLL5msh2FLdNbiYZL09ilIGFhO1SOJ/sVa+TSQScstLwc0ChZIzJCb4aHwpUCzW M8dzjzyBW/Do8kcJZDQ== 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> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13777296 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 467E6376E6 for ; Mon, 26 Aug 2024 07:17:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724656622; cv=none; b=Gte5B0fE6mwdCzAjmQTsoz8ow1tVddX1nFBAn/ml7FIuTnJCjeJcmp7CNkypNqE5c4SXsQDNiS3fR/ZzpSIGZiClTvlG+h9xj9BovDsCUPb3d0OD3BQu/NbMRnTC/tcJqTFX66fECxhIS7j/CAIJbnvF8SjzZfS//0ES7BgQThM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724656622; c=relaxed/simple; bh=nkaV0XfZaGR8p4drm8Z0uuSWaFZNEisvVSIAR+WDUHo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=HVaiRIntJL3jlmPUH4RxwUANTBmS8ww3H+kKqIkWhOc0F3U9dqP+0zusgEbNbDmdov5xz936KgiWrdk1mfRlrPcrs5BZWObTxZM9fV/J4xg9xEClrNNscIg9G1l07HMG0PvnNraDHG8XrPGNaamSjUf/nBNpvvKLD5sjyYXDH0M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--manojvishy.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=p0OdKM84; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--manojvishy.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="p0OdKM84" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6b46d8bc153so76180317b3.2 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=vger.kernel.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=p0OdKM84gBXJQraTCLy+tSZWZKE2YyZmYtlJsAWjKLlagKalCjqqJQAuusiRpaDsor zfOA0vVU4rSNXLJ+tUmTm2wint3ktYkHWEZwW55ohL8Y9rctI8wAQ9YIuW6sbIYjPL08 Re6ScDz5ZIIjo1Bpst30tI3JYc3wrCMQI/8/hpvwU0njyNl3ymyf5E4stUH22FI4FmVe uZ5CSzOd1Gt6O32FTMZ6TMLQIG4U7PzmLFT5UFvZSpunJuETvw14NyIvKu3ltHnL2XxM q3Fvtay8g4K3KYSqdwVqJ7e7PMCp6QSTfEfa2eNMwkNtcnC9BU4yxiXxhZ4gFTtzMfLd JIag== 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=gIFvSo5vXjyuyLiwiP2lxOBC4dPC+6M64sxRC90c8UBEYNz0u3vHdvw7yR/4v5Eqa3 L6TYf4aI0elb2zdg66LMR7VhB8IethZPyL7VffwWie+4KBmd7BXTLZXMnQ6b7k4EW90J qXT0S9vTiqP3vsXdIIKHngFJq1HuY8mZfKvvYXgV5h5hh+NcspXr0NBHk5GE7/F4iS/u xkvI/kS8OdJgUzIfwaENjfPmEYJOQt8FWLsgSY98ocrXofirlDxIDeBepyKCb8i7Idd8 ccJ48bcO7q4lWDgd1TM2eEouAzK+YqTPHPBzF/L3RWL8XO7AMn0vkAUeBoTaag+Uh2tb 6RJg== X-Gm-Message-State: AOJu0YyZaquehrD22sN+zRsSYrtZefoohcKXskMhEkfdsjJ3Gr0aVURj 5W/QqGQYn0Q1hgt95EI8pLjePBjFY4DfIgfQsySg1JqhRZ5IUzIqIRJFrdVd5DYPvvmMjMB0WS3 KBcWxbFpAPg/den/lwQ== 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> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13777297 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 225FA13AD20 for ; Mon, 26 Aug 2024 07:17:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724656625; cv=none; b=urlqc+GjrnC6DQ2SW9I5cewT/K1yLMIr8ks5WJ3Jcpmc0lUsjCLfssVzwfETk12dT9dMVf+KkIWHkWjEMMa1CBvs5vHMoUryd6rpsyhmP074PC63UALgap4gPMYxLhY6FBBE/1r48uItvaQAy68BefWuBAnYDRQoa+LSP/+wBxo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724656625; c=relaxed/simple; bh=FwDerl9XfOepzosKt3JEHoXPHsvu6Cl6My4q4umLuAQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=JepUPkoV53vkJbKrW+rbVLj5T7qe5eD+7dUSQfvvzqh0GZEmUxgqIjIBf9xgzVmDgjemktS/wf9n5HbvZ8tw0vtL0rVdOKsoiY/H9th1xszQ7pcc+RzYIJacznj3NMg7Am/BgLv1dXn/yjkhrHgocpsp5gOwnrWsTHrX7P8oATE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--manojvishy.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=zMJid53t; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--manojvishy.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="zMJid53t" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6c3982a0c65so75717877b3.1 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=vger.kernel.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=zMJid53tpcWt43X2JLusCAyiQLgL6b/54PsIBLumkvGOMPFGuEBiVoWDSf/W6CwotL UFMf/N2a9fdsbghEA1zwtYZ++eNQloWnhYNqFTCpuvR4Er2gXA0rCZzGMtFjv7HwmjNh Ye5xt/gL9PGzcI/6bBTVSYOFAQ2gB3F5QaxliS3mgXcAKfh3DvYmrwj6tGVdzOtSO4nl vvVzyrZ8wVdiyttg55L0HKxoclF53Sh61BKhf4za34AIxsk6D3W4OGQrGEMxCJCDZgap 3jR5UuoxZ9ndP2Sax23qp3sYE1avdaGxaEY9y++sxb7/dkygCve2xiBsaLyiKxIyi29D GUvQ== 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=B9T28hOgkOdhL/nxM/sk1yOqGRrla0RY9aEsSqW02TQLjp+28HzwP/AqiOv7MJKAEq +QJxMvIzjasJzScZv/XXvXTyTgN4P+595Z4HuSVJYYwRRmkDobTx73/z8mZiCg9nh8T9 E7TfQWj3+4usEUN/p9IYr3YgASITYLpAou+53Lr1+kDMznebRfjJvAuhDakFaXOdqOZv o8RtFAT/ijKAbuu+YT396gHYLDCjzUvZQBGtguxWXB77xA4KCvc7uGIn9ezkuf6jQ455 Eh5OPgXPtqPwqD9rsYrKJG7msEOZ5si+aueDDk6vbKFWx2v8eeZsqoALoi7h1LTmYpia L4vg== X-Gm-Message-State: AOJu0YwBzyBmyIVMU1lFqTdNBMz5ObT6Rq1eyS09KxBJpXv4pZlVX5kr CfwB1wmpSIiYtHz2GUkTS7aMF9Vfdr6p57AMz84CWxXGLT06k84gNfiN2aUpNgm/kCBo9czhjPw mEA1EEmJ9nwrOpj3hmw== 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> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13777298 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3035913BC1B for ; Mon, 26 Aug 2024 07:17:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724656629; cv=none; b=XAPMHiZtsGdGd+cvzGrLs1tMep7Y0WC1rloj5ynDh5JxjJSay613/Vo8A6OWoK7ZQlKQzjYW1bfSLNBS2JsI0K4eRRW4tRDTWG+RVMRlwmOdmU4hL3y0DzlVFJQVOkyK1ZoIxg0EikRZo3zoCSga/sft0bsZM+tgSeJUxx64gDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724656629; c=relaxed/simple; bh=MZZj2SAvpagdGOtXPGGnDmJg+RAzKw+H3OQrffzD+8w=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=MMJu1S6/k6Qcwy82o36hg+BChgeIWUsf+6tMAlGRdnSMJNHqklXwNoYzjSeLPxn+6FdiOh4QhQXmsaqoqXC1r7KHMzTe6zp7ph+vrPx4059NjG0AGyq9vXlbZvnkyIUU4+waIoVmgCLj/D91E6LV7ugOXJc32nTkJhqBBgTQ/sE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--manojvishy.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=UXcf/bD9; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--manojvishy.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="UXcf/bD9" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6b198ecf931so50453957b3.1 for ; Mon, 26 Aug 2024 00:17:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1724656626; x=1725261426; darn=vger.kernel.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=UXcf/bD9d6JZBbxuUTzPYT8zpr4pYMPLj8VX0tGZHpyA2VbKkuvrmS2um2l/mwJDeH Leay1xl6dfAHMzrW1HnFf77Qh3jjMOuUtJzp3kEF57furKynJzGY1TZqdzITq+s1AFHa IJW8QwuMv5JXbTDt7ZAUT82FGnE/NjcbyUUI/sBu9zPjh7QAKCrABhCxV2zJKXq8PsBR iDybzlVeBNuO5T4rAYcenFqVKAerfMfW8J0zybLT5qdmq19ijebqhLQPEvrQ/XdPdUQ3 RmAiTlM4nrQvvJgm4ejxgJaVl6Ie26IH5DUBtHdRBUvQbPeoJ1afszizfzDT0tDMNHVT h2aw== 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=LLDhMpLLCZwWLvhjR+WSVmTmuldvbOiIlTs1zbHQEOODK58qmENb92AeEcAiJjZ73G AiO7Uq/2m4e+gacp0FoUGQyBnDXXR5rvLT7HinO1THfW/DfugX9tjkzMuUg1BLH9ZWTc oVqiGh+REx/FT/dBXHhZH0HLiJ2Mx6zpVHEchtk2AcWedviNAgq896G+o5LM1wsXs0H9 IxHdYns3ZASNjEQEvfGhLolVALY2vfrqBxJml2ukgVS7R9t/aMOet5ToDeFrbyggRIa8 8w/9STcUBQ/RzeEEGqVcNC2dNJ0ZrEZh2VnvfG9Bq/KiDdrhiMhcxCSU5VWj6PbLogrQ auUg== X-Gm-Message-State: AOJu0YzU59+rn1z35q7yBg6pv8A4JHNnHrTmMqf2saeiR72fVKUOeOt+ NorGTLDHs/knCvdLGqAXZbNNYT/ea419tdWOur7CFUzK2bje5UDVJGqo8+e/3Cz8pLKpppGXOUU P7GMz3v4ZvP6gyfF2Ww== 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> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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);