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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75A5AC433FE for ; Fri, 8 Apr 2022 14:00:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F2D586B0074; Fri, 8 Apr 2022 10:00:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EDCD06B0075; Fri, 8 Apr 2022 10:00:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D57498D0001; Fri, 8 Apr 2022 10:00:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id C4DC36B0074 for ; Fri, 8 Apr 2022 10:00:01 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 93D0B620C7 for ; Fri, 8 Apr 2022 14:00:01 +0000 (UTC) X-FDA: 79333870602.05.646024D Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by imf31.hostedemail.com (Postfix) with ESMTP id A424720002 for ; Fri, 8 Apr 2022 14:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649426400; x=1680962400; h=date:from:to:cc:subject:message-id:reply-to:references: mime-version:in-reply-to; bh=vzRh1a2g1teZIO284W8xK+WsiWROyR/t9wQMFIz6/+E=; b=R+iFzD7Jag2yOhwoTGzbzGq0rNr2cHGyZs2plEFSXOPv7C0+gQBQFc+g B6qU7dI8ubimvLLVM4WxAfPTMzTGAT7z4ni9JFxN+5+3WeCKoFl2QYOh5 5RH7WeCHw/8pKqpvhkDc+zUJuiwD7wdt3Ta7e64mblKvHSd7pJJGOwjEL GjRNHuu6ocnGFCN0CcIjvIuZYe2zkJOHdqAZy48gGR6u42n2cD5LVdwuS SBt/4xAANshNGbjtEWkHpm+3mjW7c+CR6a32ddkOmdDzRoPrCutSKEyIJ IwrrM/Qog9q92f1a7NvxN0E/WOip6d2qYJX6fg3OjZsqpKWuY+dLV2rXN w==; X-IronPort-AV: E=McAfee;i="6400,9594,10310"; a="259195893" X-IronPort-AV: E=Sophos;i="5.90,245,1643702400"; d="scan'208";a="259195893" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2022 06:59:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,245,1643702400"; d="scan'208";a="698190261" Received: from chaop.bj.intel.com (HELO localhost) ([10.240.192.101]) by fmsmga001.fm.intel.com with ESMTP; 08 Apr 2022 06:59:52 -0700 Date: Fri, 8 Apr 2022 21:59:41 +0800 From: Chao Peng To: Sean Christopherson Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, qemu-devel@nongnu.org, Paolo Bonzini , Jonathan Corbet , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Mike Rapoport , Steven Price , "Maciej S . Szmigiero" , Vlastimil Babka , Vishal Annapurve , Yu Zhang , "Kirill A . Shutemov" , luto@kernel.org, jun.nakajima@intel.com, dave.hansen@intel.com, ak@linux.intel.com, david@redhat.com Subject: Re: [PATCH v5 07/13] KVM: Add KVM_EXIT_MEMORY_ERROR exit Message-ID: <20220408135941.GF57095@chaop.bj.intel.com> Reply-To: Chao Peng References: <20220310140911.50924-1-chao.p.peng@linux.intel.com> <20220310140911.50924-8-chao.p.peng@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Stat-Signature: 9cdxbyubxu9jrcsmfhfffepttyqzp1mk Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=R+iFzD7J; spf=none (imf31.hostedemail.com: domain of chao.p.peng@linux.intel.com has no SPF policy when checking 192.55.52.93) smtp.mailfrom=chao.p.peng@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: A424720002 X-HE-Tag: 1649426400-66424 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: On Mon, Mar 28, 2022 at 10:33:37PM +0000, Sean Christopherson wrote: > On Thu, Mar 10, 2022, Chao Peng wrote: > > This new KVM exit allows userspace to handle memory-related errors. It > > indicates an error happens in KVM at guest memory range [gpa, gpa+size). > > The flags includes additional information for userspace to handle the > > error. Currently bit 0 is defined as 'private memory' where '1' > > indicates error happens due to private memory access and '0' indicates > > error happens due to shared memory access. > > > > After private memory is enabled, this new exit will be used for KVM to > > exit to userspace for shared memory <-> private memory conversion in > > memory encryption usage. > > > > In such usage, typically there are two kind of memory conversions: > > - explicit conversion: happens when guest explicitly calls into KVM to > > map a range (as private or shared), KVM then exits to userspace to > > do the map/unmap operations. > > - implicit conversion: happens in KVM page fault handler. > > * if the fault is due to a private memory access then causes a > > userspace exit for a shared->private conversion request when the > > page has not been allocated in the private memory backend. > > * If the fault is due to a shared memory access then causes a > > userspace exit for a private->shared conversion request when the > > page has already been allocated in the private memory backend. > > > > Signed-off-by: Yu Zhang > > Signed-off-by: Chao Peng > > --- > > Documentation/virt/kvm/api.rst | 22 ++++++++++++++++++++++ > > include/uapi/linux/kvm.h | 9 +++++++++ > > 2 files changed, 31 insertions(+) > > > > diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst > > index f76ac598606c..bad550c2212b 100644 > > --- a/Documentation/virt/kvm/api.rst > > +++ b/Documentation/virt/kvm/api.rst > > @@ -6216,6 +6216,28 @@ array field represents return values. The userspace should update the return > > values of SBI call before resuming the VCPU. For more details on RISC-V SBI > > spec refer, https://github.com/riscv/riscv-sbi-doc. > > > > +:: > > + > > + /* KVM_EXIT_MEMORY_ERROR */ > > + struct { > > + #define KVM_MEMORY_EXIT_FLAG_PRIVATE (1 << 0) > > + __u32 flags; > > + __u32 padding; > > + __u64 gpa; > > + __u64 size; > > + } memory; > > +If exit reason is KVM_EXIT_MEMORY_ERROR then it indicates that the VCPU has > > Doh, I'm pretty sure I suggested KVM_EXIT_MEMORY_ERROR. Any objection to using > KVM_EXIT_MEMORY_FAULT instead of KVM_EXIT_MEMORY_ERROR? "ERROR" makes me think > of ECC errors, i.e. uncorrected #MC in x86 land, not more generic "faults". That > would align nicely with -EFAULT. Sure. > > > +encountered a memory error which is not handled by KVM kernel module and > > +userspace may choose to handle it. The 'flags' field indicates the memory > > +properties of the exit.