From patchwork Tue Oct 20 06:18:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A. Shutemov" X-Patchwork-Id: 11845757 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 19EC514B4 for ; Tue, 20 Oct 2020 06:19:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C82DE22282 for ; Tue, 20 Oct 2020 06:19:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="Jaw6HndA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C82DE22282 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AAB086B0070; Tue, 20 Oct 2020 02:19:10 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9E81A6B0071; Tue, 20 Oct 2020 02:19:10 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 85D086B0072; Tue, 20 Oct 2020 02:19:10 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0222.hostedemail.com [216.40.44.222]) by kanga.kvack.org (Postfix) with ESMTP id 554D06B0070 for ; Tue, 20 Oct 2020 02:19:10 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E8F3182E5939 for ; Tue, 20 Oct 2020 06:19:09 +0000 (UTC) X-FDA: 77391301218.10.top77_321055b2723d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id C6AD216A0B9 for ; Tue, 20 Oct 2020 06:19:09 +0000 (UTC) X-Spam-Summary: 1,0,0,4a3527cb066c4316,d41d8cd98f00b204,kirill@shutemov.name,,RULES_HIT:41:355:379:541:960:973:988:989:1260:1311:1314:1345:1359:1431:1437:1515:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:2736:3138:3139:3140:3141:3142:3352:3865:3867:3871:3874:4250:4321:5007:6119:6120:6261:6653:6742:7901:10004:11026:11658:11914:12043:12048:12296:12297:12517:12519:12555:12895:12986:13069:13161:13229:13311:13357:13894:14096:14181:14384:14721:21080:21433:21444:21451:21627:21990:30054:30062,0,RBL:209.85.167.65:@shutemov.name:.lbl8.mailshell.net-62.8.0.100 66.201.201.201;04yrczkcrzo8qbatath6iypa83rpeop17xm3tfx8u39mwfk3khj3onqqtxcy6g5.ys9cfr1ax97qr9nxcte11xtofxyy3riuaraf3qx1cjncqrtouyi4a33srr3zc9i.k-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: top77_321055b2723d X-Filterd-Recvd-Size: 4870 Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Tue, 20 Oct 2020 06:19:09 +0000 (UTC) Received: by mail-lf1-f65.google.com with SMTP id j30so674541lfp.4 for ; Mon, 19 Oct 2020 23:19:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qLURW/jdlNSmWtGV7khIZIL/9JX3uhBDJsl3glpsKS8=; b=Jaw6HndAu/3od4pm499wgLo/PnSpOsgf0qKVfrKZ1ObrIz2yUpappsJVWeGMaVAqNO zSq3AWMELJvDUUtpU8pJz+MZT0jeQQR7iN/Ls98p1ehKXFap4WGihAI3j73Y43ME2ILD Qx9R8kIrkKBMrnE5Wz8ug5w+u3Gub5ePmKcDsf5JJtjgCQkVIFtvxx25WrErKV8U4Dve P5UiLdHJzlXicKgNe8Ov+RGhPZS9rX9WxGEc+5yZ68LNby4EsxZ6T9FgHRrW74PIhXab OHvYo/0kDIK1WRTZvuBsBjo02CVVdOGsKHYcx7W8ewU4ZIqOMNtSxDmApLflbLxA5FA5 zJeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qLURW/jdlNSmWtGV7khIZIL/9JX3uhBDJsl3glpsKS8=; b=Z6hvfJT2uUvXBmhaqTxx9CuaCuLTk/WA2gq+AwT7YlzL6zwRT+vIxg1n4BevztXU50 k8XbtsRrohBbUihJeDB9i9BwAnL4fZtUN5h2nJm6PEBu4bkVhRgbMwzGzNQWbN7zDZ+v 4WreQ0cRT5emzzYkVq3Ie+bOYVnwWcb/6zKJSLflEwex1970GJFlrmVvD4kWzVcwMKDQ UEGfuSv3Gb+hF//kCx5gpGkTOtYS5ttV/ow0fnz3yLlz58Qt9GQR+ljWiSkS37NApbnL H6gXMXI5sBefFQ/popyFbFIp9e+S0GHojaBz1v94yE92gEDLWwjce40ck8k62OEZde5S WQVg== X-Gm-Message-State: AOAM530lSX3+Z/qy0po56/l1y8fizuEGCQkBeMX/uUX+A9sELfTczUUj 5pGMuQ82Ijiid3gI4n+o05VmuQ== X-Google-Smtp-Source: ABdhPJyKeklJAljBMnRznV5JsOkA5QkHO53L5Td3aC6wSbikok2iDHFkX0MnaQa4ylGJgw8He3Cn1Q== X-Received: by 2002:a19:64b:: with SMTP id 72mr395872lfg.47.1603174748148; Mon, 19 Oct 2020 23:19:08 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id m30sm136843lfc.97.2020.10.19.23.19.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2020 23:19:06 -0700 (PDT) From: "Kirill A. Shutemov" X-Google-Original-From: "Kirill A. Shutemov" Received: by box.localdomain (Postfix, from userid 1000) id D79B8102F64; Tue, 20 Oct 2020 09:19:01 +0300 (+03) To: Dave Hansen , Andy Lutomirski , Peter Zijlstra , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel Cc: David Rientjes , Andrea Arcangeli , Kees Cook , Will Drewry , "Edgecombe, Rick P" , "Kleen, Andi" , Liran Alon , Mike Rapoport , x86@kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [RFCv2 05/16] x86/kvm: Make VirtIO use DMA API in KVM guest Date: Tue, 20 Oct 2020 09:18:48 +0300 Message-Id: <20201020061859.18385-6-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201020061859.18385-1-kirill.shutemov@linux.intel.com> References: <20201020061859.18385-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: VirtIO for KVM is a primary way to provide IO. All memory that used for communication with the host has to be marked as shared. The easiest way to archive that is to use DMA API that already knows how to deal with shared memory. Signed-off-by: Kirill A. Shutemov --- drivers/virtio/virtio_ring.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index becc77697960..ace733845d5d 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -12,6 +12,7 @@ #include #include #include +#include #ifdef DEBUG /* For development, we want to crash whenever the ring is screwed. */ @@ -255,6 +256,9 @@ static bool vring_use_dma_api(struct virtio_device *vdev) if (xen_domain()) return true; + if (kvm_mem_protected()) + return true; + return false; }