Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp1659309rdf; Sun, 5 Nov 2023 08:29:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IEO3euP9w7fTYNZWGH9HW90T4iW7HiENExH7qTqzTEXbasKq+uzq0lKQkVCXqHto9h3eecH X-Received: by 2002:a05:6a21:3b44:b0:180:eef7:b3bd with SMTP id zy4-20020a056a213b4400b00180eef7b3bdmr14474229pzb.28.1699201763511; Sun, 05 Nov 2023 08:29:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699201763; cv=none; d=google.com; s=arc-20160816; b=f7PvAFNzJx80Ur2OrcqdDWk/V0OelCuhU6UThZdNMUKkWmRxTItQ4iZu+FfbTQ9iOP QScIepmpELZ9jeo0VSsRcftByYnLT/gDr0o3IyRaw2ULp9Cxxacx/M3fiUGpvAXZPg2e QYvBBbSIP+S5y8tJNVxjcxpbcQJZ1+X6ChLL24zGKXcjuxjk36RpT/Xm3ag2GLr0/dNe VR5skYUPRdhOHc4wxI2n28FsRQdxjyjzZkQL8htkTOebZLbVk1S8lnsUDcwSq8WMAyHM aro0hUHJ94RqhrSi0rkvvSIeopLHobq50ky37erwZ6I9Hqncqs7P2Od9RfRXjnusimse Auog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=5S45DCFEET4FUlleAs+X25SSP8exRtkoxGaiIZR36AY=; fh=09YmTepD7RFvYIg0XkP6amoKPiBnvGqC3/ffNeODMtA=; b=ookc1bPjVok8yWE63xBoOxCX6c2HN9UQhqkMmWR9DMhzfJzr3do+6zsTq9C7tgFNVE YdqMB8Qiu4dfR0RwblnqXckqqnrv2BjnCWBi+uEehWPXRTebKn4LBBYEeML7fYZtJzyz aVjfQohk4qF/35BIUexDg8+SkRMfDHVMYsNEVhWkxp5STenyai4so/zGO1/iC14eVoo+ u3Gyu1O03HDjbysNd4anIjYRazlvqAbyaE9DABjpkUFvDPE1RlDiYisrReXZ/WF+EEYk neA2gQ49GH4OaNZ8X/B3B9OweIl6954yuFtnWCrTG4FC//Ywzf8ofxvPOCIkOnlu4Uid uixQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Qs3HRrP3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id me11-20020a17090b17cb00b002534f4ce2b6si6795691pjb.125.2023.11.05.08.29.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 08:29:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Qs3HRrP3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 2D05A8087B79; Sun, 5 Nov 2023 08:29:20 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229436AbjKEQUn (ORCPT + 99 others); Sun, 5 Nov 2023 11:20:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229524AbjKEQUm (ORCPT ); Sun, 5 Nov 2023 11:20:42 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E9B6DE for ; Sun, 5 Nov 2023 08:19:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699201191; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5S45DCFEET4FUlleAs+X25SSP8exRtkoxGaiIZR36AY=; b=Qs3HRrP3qIhpoKM72TcYby7LjkynOYF2uGUiYgOpf4cM1NTdPhrht9wGz/KnO3gBjJxfUq mza5kadjnoQ8KRXMz4halkRbOGmF7JZQRnmEXEipVlcbqxqYJs2bJ/KxI1kMpBJJetCEJF dDxtT0VknqS2ie5C9oxIB6gY14EdZkk= Received: from mail-vk1-f198.google.com (mail-vk1-f198.google.com [209.85.221.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-68-DV5Uv0HoPz6PrJx3jndauA-1; Sun, 05 Nov 2023 11:19:50 -0500 X-MC-Unique: DV5Uv0HoPz6PrJx3jndauA-1 Received: by mail-vk1-f198.google.com with SMTP id 71dfb90a1353d-4ac2ffa81f1so312122e0c.0 for ; Sun, 05 Nov 2023 08:19:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699201190; x=1699805990; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5S45DCFEET4FUlleAs+X25SSP8exRtkoxGaiIZR36AY=; b=vyb61WUi6UEm+aPl9IAn8KUzOJQp7HW12/hIPvAL2+GI22ryMzYOqKe6z5KAhC7DU6 PSvBYX+Dswq4JQvMQXPMwRxVGRq0kVSIfT5r6KQebIbs/P33qY89Yi4qX6EwCd2QNqWA EXEatdIx3vxz3WuxfWCAZf7vL+rywCDSygvvEeqT/iYbVlEigXnzMlnXslWbR/E6I+qE pwkKuTiCy6p16TvF5k1eIpcf/GmnpjUPLivIlkKrzKkAXcNpCbHmFpbCxh56XY+ED3Qh 1rB+E3p//eLryKEQ/aVVK2IXd1SwhGPSJZbX1rV2dQXXLbAAaXotCGZhWO0tJTpo8kJA DL/w== X-Gm-Message-State: AOJu0Ywm2JnWg05IJwpKhC3Cs0c72jMb5uEmt4f+sZPUmanF1w+j2Hlp CaOESA+sLCW9yJ4lQJoUM/5Quy37w18V9AYWQPNJ7vaUU3HM+B0p8wXZxfb6BlWLUofY1z/w9p4 iPoDbKP0O+RyeuUOhwO+05gWQtDL73kPJ/Xj0dQn1 X-Received: by 2002:a05:6102:4743:b0:45d:8f83:e10f with SMTP id ej3-20020a056102474300b0045d8f83e10fmr5351504vsb.4.1699201189803; Sun, 05 Nov 2023 08:19:49 -0800 (PST) X-Received: by 2002:a05:6102:4743:b0:45d:8f83:e10f with SMTP id ej3-20020a056102474300b0045d8f83e10fmr5351461vsb.4.1699201189503; Sun, 05 Nov 2023 08:19:49 -0800 (PST) MIME-Version: 1.0 References: <20231027182217.3615211-1-seanjc@google.com> <20231027182217.3615211-21-seanjc@google.com> In-Reply-To: From: Paolo Bonzini Date: Sun, 5 Nov 2023 17:19:36 +0100 Message-ID: Subject: Re: [PATCH v13 20/35] KVM: x86/mmu: Handle page fault for private memory To: Xu Yilun Cc: Sean Christopherson , 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?B?TWlja2HDq2wgU2FsYcO8bg==?= , Vlastimil Babka , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A . Shutemov" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Sun, 05 Nov 2023 08:29:20 -0800 (PST) On Sun, Nov 5, 2023 at 2:04=E2=80=AFPM Xu Yilun = wrote: > > > +static void kvm_mmu_prepare_memory_fault_exit(struct kvm_vcpu *vcpu, > > + struct kvm_page_fault *faul= t) > > +{ > > + kvm_prepare_memory_fault_exit(vcpu, fault->gfn << PAGE_SHIFT, > > + PAGE_SIZE, fault->write, fault->exe= c, > > + 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 =3D 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 !=3D -EFAULT? The cases are EFAULT, EHWPOISON (which can report KVM_EXIT_MEMORY_FAULT) and ENOMEM. I think it's fine that even -ENOMEM can return KVM_EXIT_MEMORY_FAULT, and it doesn't violate the documentation. The docs tell you "what can you do if error if EFAULT or EHWPOISON?"; they don't exclude that other errnos result in KVM_EXIT_MEMORY_FAULT, it's just that you're not supposed to look at it Paolo