From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E62E6C55179 for ; Fri, 23 Oct 2020 10:36:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 318292225F for ; Fri, 23 Oct 2020 10:36:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="fhbRPsyb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 318292225F 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 4E9B96B005D; Fri, 23 Oct 2020 06:36:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4761F6B0062; Fri, 23 Oct 2020 06:36:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 33AFB6B0068; Fri, 23 Oct 2020 06:36:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0224.hostedemail.com [216.40.44.224]) by kanga.kvack.org (Postfix) with ESMTP id 00CA06B005D for ; Fri, 23 Oct 2020 06:36:13 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A0129180AD811 for ; Fri, 23 Oct 2020 10:36:13 +0000 (UTC) X-FDA: 77402835426.20.sheep74_071717527258 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id 80492180C07A3 for ; Fri, 23 Oct 2020 10:36:13 +0000 (UTC) X-HE-Tag: sheep74_071717527258 X-Filterd-Recvd-Size: 5594 Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Fri, 23 Oct 2020 10:36:13 +0000 (UTC) Received: by mail-lj1-f193.google.com with SMTP id m16so1026035ljo.6 for ; Fri, 23 Oct 2020 03:36:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2qkq9CfQOJr8zJttsFKuFINhGnc+H3tDfc2bDWRdxKM=; b=fhbRPsyb8i9xNHMf4eL5ienqhn7upoD6FePa/IEF7DMBI6HisVrOD33691JnVkmeQi ET2W5Takymxk8FVZvUA5hEAmwX7HYwQurYbORAkttNqTL4VuRwkIkfZ0h/JLlpG+GR6u a6BWrna+MBVKLQ9UAl6mF4AeywD0FcFeHeltPhaw+5YZUumYlpF1v4IBLvpmcnJozg9Y mdYng2/8mGvFa8kUyHbVE6+aKlNVE+cfharL9bJyzKCwIk0S5XbJIlfVAvfrxBP5+Heo ouekvBs9rnWndDp/Nb7lQTKqSqykoCFGoOQ+zBx0i7e4ynHDUpbUISETkwzCkX6DMDnH 3oJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2qkq9CfQOJr8zJttsFKuFINhGnc+H3tDfc2bDWRdxKM=; b=iWsHYDAo3EaES51c3oUeAf6IKibDvUTI/y6E3ToFSdi0wjQMXEsKZUI7pb7+XWpSC0 JfYYjO9RgOI9AhyXo3HZcf+b72BWxthiW6VN8j4bGZapDthvziviwHKoMYZNQ34d678h I8JNWPisMqyGgiyIE6M/kKtTAeMss0KoTMUpgbOS29Og+RBOkLP0ZZsD6g/wGkFxBuPz xNrCF3oPvL532m7pltFNJhF0gJ6wUmfKzk9F8cT7xZShH7Ywvwu21P96Mqs86E6iWp47 7K3igTI2fcOJI+0p1NKO1FvTazyq6NhPkseA9X2bFOawCGm7T7PQGI805bqSaSA+wI5M bDOw== X-Gm-Message-State: AOAM531rkFaDCW7Onn7IKwvfNkZxfi1j8PAqxuQh3+HU3GUsZWFJNMAx Tnh7RQcpZdZVgcYeklIFgybW5g== X-Google-Smtp-Source: ABdhPJxQnKcTu7fqc4QutnnpTAjI9nHlJriPNvSeoN91l9+74XgAkQagFMHTs4++JLMhsXVHrZdecg== X-Received: by 2002:a2e:b889:: with SMTP id r9mr639609ljp.378.1603449371412; Fri, 23 Oct 2020 03:36:11 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id x18sm99408lfe.158.2020.10.23.03.36.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 03:36:10 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id D5683102F98; Fri, 23 Oct 2020 13:36:10 +0300 (+03) Date: Fri, 23 Oct 2020 13:36:10 +0300 From: "Kirill A. Shutemov" To: "Edgecombe, Rick P" Cc: "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "jmattson@google.com" , "peterz@infradead.org" , "kirill.shutemov@linux.intel.com" , "Christopherson, Sean J" , "vkuznets@redhat.com" , "linux-mm@kvack.org" , "dave.hansen@linux.intel.com" , "joro@8bytes.org" , "x86@kernel.org" , "aarcange@redhat.com" , "keescook@chromium.org" , "luto@kernel.org" , "pbonzini@redhat.com" , "rientjes@google.com" , "liran.alon@oracle.com" , "rppt@kernel.org" , "wad@chromium.org" , "wanpengli@tencent.com" , "Kleen, Andi" Subject: Re: [RFCv2 14/16] KVM: Handle protected memory in __kvm_map_gfn()/__kvm_unmap_gfn() Message-ID: <20201023103610.facpukoiodnj5v73@box> References: <20201020061859.18385-1-kirill.shutemov@linux.intel.com> <20201020061859.18385-15-kirill.shutemov@linux.intel.com> <8404a8802dbdbf81c8f75249039580f9e6942095.camel@intel.com> <20201022120645.vdmytvcmdoku73os@box> <4df3bb56f56f5a8d69b4b288317111046158cebb.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4df3bb56f56f5a8d69b4b288317111046158cebb.camel@intel.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Oct 22, 2020 at 04:59:49PM +0000, Edgecombe, Rick P wrote: > On Thu, 2020-10-22 at 15:06 +0300, Kirill A. Shutemov wrote: > > > I think the page could have got unmapped since the gup via the > > > hypercall on another CPU. It could be an avenue for the guest to > > > crash > > > the host. > > > > Hm.. I'm not sure I follow. Could you elaborate on what scenario you > > have > > in mind? > > Kind of similar scenario as the userspace triggered oops. My > understanding is that the protected status was gathered along with the > gup, but after the mm gets unlocked, nothing stops the page > transitioning to unmapped(?). At which point kmap() from a previous gup > with !protected, would go down the regular kmap() route and return an > address to an unmapped page. > > So the guest kernel could start with a page mapped as shared via the > hypercall. Then trigger one of the PV MSR's that kmap() on CPU0. On > CPU1, after the gup on CPU0, it could transitioned the page to > private/unmapped via the hypercall. So the hva_to_pfn() would find > !protected, but by the time the kmap() happened the page would have > been unmapped. Am I missing something? We need to fail protection enabling if a page is pinned. That's the only option I see. But it might be pain to debug. -- Kirill A. Shutemov