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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 46DF2C4332F for ; Sun, 5 Nov 2023 16:20:55 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GIFXajrq; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GIFXajrq; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4SNfq95jXNz3c7q for ; Mon, 6 Nov 2023 03:20:53 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GIFXajrq; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GIFXajrq; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=pbonzini@redhat.com; receiver=lists.ozlabs.org) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4SNfp91Sdtz2xpx for ; Mon, 6 Nov 2023 03:19:59 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699201194; 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=GIFXajrqm/ULsy1Olv8nSw+qy6pTHQDi6LF0IHzUOTjwt5taiG65RjGqrE9NCr6POVy6Ba crP26QRpr6wp29snVzITIettqV+Ny+qHTCSFO4w1w58RGIkgnsaIed3UEkaMJywJLxl3w7 7SC5QJ7qCa55AeaSXl8RPex8tSmM5C0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699201194; 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=GIFXajrqm/ULsy1Olv8nSw+qy6pTHQDi6LF0IHzUOTjwt5taiG65RjGqrE9NCr6POVy6Ba crP26QRpr6wp29snVzITIettqV+Ny+qHTCSFO4w1w58RGIkgnsaIed3UEkaMJywJLxl3w7 7SC5QJ7qCa55AeaSXl8RPex8tSmM5C0= Received: from mail-vk1-f199.google.com (mail-vk1-f199.google.com [209.85.221.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-623-Zugk040eNPu4C9f1dqfNjQ-1; Sun, 05 Nov 2023 11:19:50 -0500 X-MC-Unique: Zugk040eNPu4C9f1dqfNjQ-1 Received: by mail-vk1-f199.google.com with SMTP id 71dfb90a1353d-4ac2ffa81f1so312117e0c.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=VYbgkxPn/GKSQ/kk22VP1VTBLZ5C6I3ZklhjfybqmrwEsmPVxQ9yCn2DVPXMv6pQkN EH3MJtnIuGbZSSXB0icI++vXVPcFZBU+S7Oz5awgEhe6jk0GHC9lLLmDNbyoq5QOZ5Ef R+GOjouDTBBusNLQUFbYa/pfYCg+UKJ/6uJU3/K3EC1rLmWcAWNBMnPIafjLM5AJcV2q R2PEmQIIAeSnzYZSsZpYIhuOHXHTbXl/tAnWoC5Nzdsafv93IS15lQdauTn6/0fy5G0I AttfPdQWFOTH+Eq/ucSIbSLeNkG+UsfuAabVCyggzWYE9JybgEZlTa9WzNXWDq8AAySi 58XA== X-Gm-Message-State: AOJu0YzsqLUW3zDzkJdqnJDTwNtAoDwPWwhaQDAd2d9EvXIBzMK0hb78 fNmgaSwcvaQ9glPtRzw6NS7DKfAKdbPLX+6+GFxWs7CLVeKeCeHjjeApbiI/yqbt2bnAjsRvHsq MeA9pkD/uAEYS/mr5HY5gpUuVOUtUYZJR4IEycIuq+g== X-Received: by 2002:a05:6102:4743:b0:45d:8f83:e10f with SMTP id ej3-20020a056102474300b0045d8f83e10fmr5351494vsb.4.1699201189799; Sun, 05 Nov 2023 08:19:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IG9PY/ps/exIZhJtEiBPcrHL5I4MFvN3fWtoZJg4K/o1jMHEXmGlTLfpUZIUzDcxTZUf1dOb3c60KPU/ucxafo= 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 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, David Hildenbrand , Anup Patel , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Chao Peng , linux-riscv@lists.infradead.org, Isaku Yamahata , Marc Zyngier , Huacai Chen , Xiaoyao Li , "Matthew Wilcox \(Oracle\)" , Wang , Fuad Tabba , Yu Zhang , Maciej Szmigiero , Albert Ou , Vlastimil Babka , Michael Roth , Ackerley Tng , Alexander Viro , Paul Walmsley , kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, =?UTF-8?B?TWlja2HDq2wgU2FsYcO8bg==?= , Isaku Yamahata , Christian Brauner , Quen tin Perret , Sean Christopherson , linux-mips@vger.kernel.org, Oliver Upton , David Matlack , Jarkko Sakkinen , Palmer Dabbelt , "Kirill A . Shutemov" , kvm-riscv@lists.infradead.org, linux-fsdevel@vger.kernel.org, Liam Merwick , Andrew Morton , Vishal Annapurve , linuxppc-dev@lists.ozlabs.org, Xu Yilun , Anish Moorthy Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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