From patchwork Tue Oct 20 06:18:53 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: 11845767 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 09B5B14B4 for ; Tue, 20 Oct 2020 06:19:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B9382222C8 for ; Tue, 20 Oct 2020 06:19:29 +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="QOwj6pUP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B9382222C8 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 4B9876B0075; Tue, 20 Oct 2020 02:19:13 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 46D006B0078; Tue, 20 Oct 2020 02:19:13 -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 2BD9D6B007D; Tue, 20 Oct 2020 02:19:13 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0142.hostedemail.com [216.40.44.142]) by kanga.kvack.org (Postfix) with ESMTP id E4C026B0078 for ; Tue, 20 Oct 2020 02:19:12 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 902373626 for ; Tue, 20 Oct 2020 06:19:12 +0000 (UTC) X-FDA: 77391301344.25.ring22_53038c52723d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id 6AF141804E3A0 for ; Tue, 20 Oct 2020 06:19:12 +0000 (UTC) X-Spam-Summary: 1,0,0,0747a0bc0e012e09,d41d8cd98f00b204,kirill@shutemov.name,,RULES_HIT:41:355:379:541:960:973:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1541:1711:1730:1747:1777:1792:1981:2194:2199:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:4321:5007:6261:6653:6742:10004:11026:11657:11658:11914:12043:12048:12296:12297:12438:12517:12519:12555:12895:13069:13161:13229:13311:13357:13894:14181:14384:14721:21080:21444:21451:21627:21795:30051:30054,0,RBL:209.85.208.195:@shutemov.name:.lbl8.mailshell.net-62.8.84.100 66.201.201.201;04yg9x3znmme5wzxa4bw6ib3kx5qrocpax7djib1skd5goh7iumb19mazjc5ro7.jre35zeyfk6pbtxb7oczj9ags5qjejsxw4gszjotitp89cnb3jxw8qx5graubdt.s-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:23,LUA_SUMMARY:none X-HE-Tag: ring22_53038c52723d X-Filterd-Recvd-Size: 4911 Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Tue, 20 Oct 2020 06:19:11 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id h20so732559lji.9 for ; Mon, 19 Oct 2020 23:19:11 -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=Y7hM+tUDAeAq4RAxUld5ugj5h0NrD2Du8CkrLpwlkag=; b=QOwj6pUPgpTDZ6ktUvy4xykf+ox4KixOkoZHuQqKEafWwwbuwhWO8H15O9F2S74Kyb aKOivTr6vej82pS6GKMyAEpN9vglV3fdogePZcExy41kgzXGzhx0JEZOYEBBgQauJfbf a4fpB0aFkwpbAZow63PKwa2cI3mLpbrXowiG8FCfuo621x3Xv+E9Yu7FMmUIwTEnAYRs OBWkoRYnDrD971FOU2wxMq0kpfZSB8vPJoBpfy+oTVo/8R14HJIBOngbE85+oA+IEQ/A B/MYw1omq+M7GBfCkdovs/HQaPgwVTpyuHY/J9z1tQkVrsaQjLFe+L8wzWGA6UrGvN0Y p+rQ== 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=Y7hM+tUDAeAq4RAxUld5ugj5h0NrD2Du8CkrLpwlkag=; b=AYMtSqF1ma+mffujQxIBpIevFfwIVSqBByQnG9Y3kAOBTMhLaxliqATaui7WSHaRpO 5MxfIjm6OaZG7QMzommaw60oKtkyOf55AwHTbiajfe/SK2llnRxvooFFUq+zD40MXDEi yoPj3+Mk1F8dFe4pSXR2qJb1MuFaxOXfK30KM71adFtXxb6/srlmBQZ5Oipe+3+vKqro +HKDxouNdG5dDAG6MhcL6RHPmSdqWTjSqCXk7zAYs3XaYetKc1VniUr+izvt/UDOvlhP W9bT1Zq3dYMltHCa4jPZb1rzJZhws4QFc8xhDNeTIdcFehE26ZTlJjFzdv+kf9AaISGD V5yA== X-Gm-Message-State: AOAM532+ErudqIfBOgwLNUdvm9pvWW6WKJ1fILE5BEjzYU1exyYACfG8 Sp36M4I7VzOemgWR7FxIeftRFg== X-Google-Smtp-Source: ABdhPJyNQOaGkoovzVmlF7h+01Jp8CyRpn89ZWIY3mQpFq+pcIj7Ik9DQ/oAPoDKgfNVHjdjAC5Vog== X-Received: by 2002:a2e:949:: with SMTP id 70mr511621ljj.319.1603174750510; Mon, 19 Oct 2020 23:19:10 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id l14sm194088lji.123.2020.10.19.23.19.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2020 23:19:09 -0700 (PDT) From: "Kirill A. Shutemov" X-Google-Original-From: "Kirill A. Shutemov" Received: by box.localdomain (Postfix, from userid 1000) id 0BAA4102F69; Tue, 20 Oct 2020 09:19:02 +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 10/16] KVM: x86: Use GUP for page walk instead of __get_user() Date: Tue, 20 Oct 2020 09:18:53 +0300 Message-Id: <20201020061859.18385-11-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: The user mapping doesn't have the page mapping for protected memory. Signed-off-by: Kirill A. Shutemov --- arch/x86/kvm/mmu/paging_tmpl.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h index 4dd6b1e5b8cf..258a6361b9b2 100644 --- a/arch/x86/kvm/mmu/paging_tmpl.h +++ b/arch/x86/kvm/mmu/paging_tmpl.h @@ -397,8 +397,14 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker, goto error; ptep_user = (pt_element_t __user *)((void *)host_addr + offset); - if (unlikely(__get_user(pte, ptep_user))) - goto error; + if (vcpu->kvm->mem_protected) { + if (copy_from_guest(&pte, host_addr + offset, + sizeof(pte), true)) + goto error; + } else { + if (unlikely(__get_user(pte, ptep_user))) + goto error; + } walker->ptep_user[walker->level - 1] = ptep_user; trace_kvm_mmu_paging_element(pte, walker->level);