Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp1562720rdf; Sun, 5 Nov 2023 05:04:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IHgYZtNB8ja5F8cA+UMkaAsYhUNl6sC6liYWB3BP/6n/lLnm3xVXzwzHjQ0MR5HWt4invf4 X-Received: by 2002:a05:6808:1493:b0:3af:a0bd:45c3 with SMTP id e19-20020a056808149300b003afa0bd45c3mr30402340oiw.20.1699189494958; Sun, 05 Nov 2023 05:04:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699189494; cv=none; d=google.com; s=arc-20160816; b=m4CXo4WbqJojT8lJBedrj1JiDIYo2l3+hR1no050IRRMypIXzlUM+YApVhcXy+I6dX ygf+xksC1ZKVh0/oN6+B1HRGNq8SppZlV+cQOKHkakJ9yeqhXr6vA4ynZAJtsAL3jYMf pftsdYIVdchSniGj5psJB1eSzMhKnE+4+eYueYW1zwWjw8dXnHKj0WfB9SzFJs/AVxmD l/Xyql+utP1RAIrbYuPeUx4NOaWhk8u7OjSlArnM/s08B51WEqlcLXaS5cA2k5J+9aKi gU/MMVtb1AOHvj2MpgwO13g6QnhcMGC05cfdzZaxBAQfSknsPYqyRzTj+McO/Q04HCYm H5fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9SMBpTiewq9uum8pa+C7PlxeCu0pFD1zXCwEef5PLCk=; fh=bkiT0m2nDSwOiS0tXX/alW1oLaKci0q7aS8wY29DT0Q=; b=ZJQoW+seYos9EureJsCPVSJvNOkGwOq/Ebykarp9pNnHi28m+wDuy/PGwyl6Nv6PoF HE5CtzKacOFar8XMaNeykvvR8mpaPC2XCGvhHSG9r52B4ahWXsp7SNspBVabMUQiFyRR fMFFU05Hl6qqG6u60PPXkYIRDuHY/LI9fLq3cd66Sj9nkRvRDgBFl7631FK+WqqFtvyF VBB9+rRPr3YpPirAxcy+ErS6/wxKlZKZU/NRwfo6peSvTqDKluS9dJulxfsidZTUIrqB H/O0D/CvMS97nORVM1TuZt2Cxwhplsp2M+lQMqEk0krPRKIbvuCcQlCQL7D7dbVzwFSR Rpww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=luiuFZ4C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id c10-20020a056808138a00b003b2a9fc7c26si2329635oiw.50.2023.11.05.05.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 05:04:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=luiuFZ4C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 9DC0B8063034; Sun, 5 Nov 2023 05:04:52 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229889AbjKENEp (ORCPT + 99 others); Sun, 5 Nov 2023 08:04:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbjKENEo (ORCPT ); Sun, 5 Nov 2023 08:04:44 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE3ECDE; Sun, 5 Nov 2023 05:04:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699189481; x=1730725481; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=mFE9c4kKSFVvQT9y1x5f+rwwI1//UOO/ul+Hvls5bPM=; b=luiuFZ4C34ioZ8qEi0FjhegFU8oLxs9xjJI0ZqSPZlVAJqksXjuHOPGq zFP4E1aWHLTglJSoEWBnnOPNXjyv5cR1Z4iQ18W+7lmve4DuYfjLc3lXN qiEWchOyAq7umFnaKStqMzfl/DvVldBT+R2CCH0Inz6IHlMIOnBbDNBnM WOhKBGCKOHlpiHYU1X5ZItHhuPMbeZ6x/mb8RLfKUbCddYJ3Kcfdq8+GW ANLaZ/PQEn95ijcmt85NWenE+wQpsMzqOUW00Y1rMFP19KwJ2/kCEPe1T 7cmPglRxXJ7Y31eN81K236x6omElW+TS6+oOQv65IIH/pSDp+vhpsj737 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10884"; a="388033715" X-IronPort-AV: E=Sophos;i="6.03,279,1694761200"; d="scan'208";a="388033715" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2023 05:04:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,279,1694761200"; d="scan'208";a="10206430" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.165]) by fmviesa001.fm.intel.com with ESMTP; 05 Nov 2023 05:04:02 -0800 Date: Sun, 5 Nov 2023 21:02:32 +0800 From: Xu Yilun To: Sean Christopherson Cc: Paolo Bonzini , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Viro , Christian Brauner , "Matthew Wilcox (Oracle)" , Andrew Morton , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Xiaoyao Li , Xu Yilun , Chao Peng , Fuad Tabba , Jarkko Sakkinen , Anish Moorthy , David Matlack , Yu Zhang , Isaku Yamahata , =?utf-8?Q?Micka=C3=ABl_Sala=C3=BCn?= , Vlastimil Babka , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A . Shutemov" Subject: Re: [PATCH v13 20/35] KVM: x86/mmu: Handle page fault for private memory Message-ID: References: <20231027182217.3615211-1-seanjc@google.com> <20231027182217.3615211-21-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231027182217.3615211-21-seanjc@google.com> X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 05 Nov 2023 05:04:52 -0800 (PST) > +static void kvm_mmu_prepare_memory_fault_exit(struct kvm_vcpu *vcpu, > + struct kvm_page_fault *fault) > +{ > + kvm_prepare_memory_fault_exit(vcpu, fault->gfn << PAGE_SHIFT, > + PAGE_SIZE, fault->write, fault->exec, > + fault->is_private); > +} > + > +static int kvm_faultin_pfn_private(struct kvm_vcpu *vcpu, > + struct kvm_page_fault *fault) > +{ > + int max_order, r; > + > + if (!kvm_slot_can_be_private(fault->slot)) { > + kvm_mmu_prepare_memory_fault_exit(vcpu, fault); > + return -EFAULT; > + } > + > + r = kvm_gmem_get_pfn(vcpu->kvm, fault->slot, fault->gfn, &fault->pfn, > + &max_order); > + if (r) { > + kvm_mmu_prepare_memory_fault_exit(vcpu, fault); > + return r; Why report KVM_EXIT_MEMORY_FAULT here? even with a ret != -EFAULT? This is different from the decription where KVM_EXIT_MEMORY_FAULT is introduced: KVM_EXIT_MEMORY_FAULT will be used to report memory faults that appear to be implicit conversions. To allow for future possibilities where KVM reports KVM_EXIT_MEMORY_FAULT and fills run->memory_fault on _any_ unresolved fault, KVM returns "-EFAULT" Thanks, Yilun > + } > + > + fault->max_level = min(kvm_max_level_for_order(max_order), > + fault->max_level); > + fault->map_writable = !(fault->slot->flags & KVM_MEM_READONLY); > + > + return RET_PF_CONTINUE; > +}