Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp105736rdb; Wed, 1 Nov 2023 19:20:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQPouVuD0IrsQsODjJHHFVSEHeyk/aZe94pGyGDnKBp/OzB7+2QFiXtncJkFE+wUg3RTsF X-Received: by 2002:a05:6830:448d:b0:6d3:1d04:55f with SMTP id r13-20020a056830448d00b006d31d04055fmr3366963otv.8.1698891613880; Wed, 01 Nov 2023 19:20:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698891613; cv=none; d=google.com; s=arc-20160816; b=wvUC1CS5M7CXhAzcYrkmRfV4EdIVvhHh7yABZqPySks6qMqIVOa2BjxxP7lazZXYl5 PGtylHwoT6mZqBn+0t4iFoSAc5djK6hSfJb857zgBocq90yTejfKpT7A1THSgEAWnlzS gzjrednD+GBLY3+lvgs1MFJcGX65T+Ka6h3HL1zpp6NcHmyHvF1mmeT8GcbBrFAqmbn3 2Y29cVI6nTfkFWes5OflNCSQ1l8hYEOEAwUaXqPZcfxSOq8Hy8uqE9e4qZP1/nZaE2s1 aTqULd8yvrEh8W5AFNODZeWUl50fA6vqtg/eXMl9VJhpnh5GyOAJN+34mdKqkJuv6hhG 0GWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=dY0Z7smCS1kHe9JjJaOLjaMy2MNGuF6q2LtbRpnMatk=; fh=1pd5+wRwSlZu4OqWunn50N/GsetZz3KhASnQ6wAAbQI=; b=HmzGv7mBNJ3JiQgtxpy0m5VtMuofsIKHLdB1ert16+6Bp137Y+gs/4BcfWFdrRBCv2 u9EpLvfyLFl7cENQ4cKOaBouq90/TG3kBn+F/Ok2XNwe/R0XwIPIFWwgzLb+zE75UpfK CJe+oxuo39QPtxFis1DRl3nc7XnKXIpkMwBVmh/LeK9Rn++RaUht8w+NGdiOSg2CxKNm i5r1H9BU8vMHXzVnfda05f7Zk3+bn1hAyWnIH91L79+M7sg7p9s+cqZEBU1Bu7SBdU2G euj/LwI7Cli3A/l4k5pUGsvvuKfIAdKuzlNxGpmK7YzXwCLwAnRZ3xzBY8Nq7DPOMwCb A0YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="LdpA/K0i"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id r25-20020aa79639000000b0068ff3a3c9d0si2700742pfg.91.2023.11.01.19.20.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 19:20:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="LdpA/K0i"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id E71AE802D525; Wed, 1 Nov 2023 19:20:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348239AbjKBCUL (ORCPT + 99 others); Wed, 1 Nov 2023 22:20:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232963AbjKBCUK (ORCPT ); Wed, 1 Nov 2023 22:20:10 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7028211D; Wed, 1 Nov 2023 19:20:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698891604; x=1730427604; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=qMSrBq5gKSfvneC99jG0ycqZi9wUzkwKrG5m2lwT0dM=; b=LdpA/K0iBInjVEGveW8ciM4zHmQ6nSMJ/VOGGNnBWn3ppc2EvW9MSsRv tv9G9s3JPgjQBZDQPURgj5BHXbQjgRj4T5FJsibP+Bq55BZudHcREyo5Q uS4bpAjwIHUznzpsyfbyeCtcAovxUJqQClWsUAN7qBq1N1vY2WFaIT2vX 2eVBptiq/3Wrw+MW3PNzaTSKAuTOoTui0V3/QPRa4hnkOe/10L7sULKaz LEyUXXgVYWqUq8zRk1eiFJmhIAJK6LZYnV1Js6LV7WPvf0CtiMo0SggU3 70HDcwXOYdJIlLFc9i82w48yQyVjwnIMdA8U5JRurucu+8RktGLM+Xhml Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="373665318" X-IronPort-AV: E=Sophos;i="6.03,270,1694761200"; d="scan'208";a="373665318" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 19:20:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="851761891" X-IronPort-AV: E=Sophos;i="6.03,270,1694761200"; d="scan'208";a="851761891" Received: from xiaoyaol-hp-g830.ccr.corp.intel.com (HELO [10.93.9.145]) ([10.93.9.145]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 19:19:53 -0700 Message-ID: <33686031-c1df-4ef5-a6ac-1aab7f5c656e@intel.com> Date: Thu, 2 Nov 2023 10:19:50 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v13 09/35] KVM: Add KVM_EXIT_MEMORY_FAULT exit to report faults to userspace Content-Language: en-US To: Sean Christopherson , Kai Huang Cc: "viro@zeniv.linux.org.uk" , "aou@eecs.berkeley.edu" , "brauner@kernel.org" , "oliver.upton@linux.dev" , "chenhuacai@kernel.org" , "paul.walmsley@sifive.com" , "palmer@dabbelt.com" , "maz@kernel.org" , "pbonzini@redhat.com" , "mpe@ellerman.id.au" , "willy@infradead.org" , "anup@brainfault.org" , "akpm@linux-foundation.org" , "kvm-riscv@lists.infradead.org" , "mic@digikod.net" , "liam.merwick@oracle.com" , "kvm@vger.kernel.org" , Isaku Yamahata , "kirill.shutemov@linux.intel.com" , "david@redhat.com" , "tabba@google.com" , "amoorthy@google.com" , "linuxppc-dev@lists.ozlabs.org" , "michael.roth@amd.com" , "kvmarm@lists.linux.dev" , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-riscv@lists.infradead.org" , "chao.p.peng@linux.intel.com" , "linux-mips@vger.kernel.org" , Vishal Annapurve , "vbabka@suse.cz" , "mail@maciej.szmigiero.name" , "yu.c.zhang@linux.intel.com" , "qperret@google.com" , "dmatlack@google.com" , Yilun Xu , "isaku.yamahata@gmail.com" , "ackerleytng@google.com" , "jarkko@kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-mm@kvack.org" , Wei W Wang References: <20231027182217.3615211-1-seanjc@google.com> <20231027182217.3615211-10-seanjc@google.com> <482bfea6f54ea1bb7d1ad75e03541d0ba0e5be6f.camel@intel.com> From: Xiaoyao Li In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HK_RANDOM_ENVFROM, HK_RANDOM_FROM,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 01 Nov 2023 19:20:13 -0700 (PDT) On 11/2/2023 1:36 AM, Sean Christopherson wrote: >> KVM_CAP_MEMORY_FAULT_INFO is x86 only, is it better to put this function to >> ? > I'd prefer to keep it in generic code, as it's highly likely to end up there > sooner than later. There's a known use case for ARM (exit to userspace on missing > userspace mapping[*]), and I'm guessing pKVM (also ARM) will also utilize this API. > > [*]https://lore.kernel.org/all/20230908222905.1321305-8-amoorthy@google.com I wonder how this CAP is supposed to be checked in userspace, for guest memfd case? something like this? if (!kvm_check_extension(s, KVM_CAP_MEMORY_FAULT_INFO) && run->exit_reason == KVM_EXIT_MEMORY_FAULT) abort("unexpected KVM_EXIT_MEMORY_FAULT"); In my implementation of QEMU patches, I find it's unnecessary. When userspace gets an exit with KVM_EXIT_MEMORY_FAULT, it implies "KVM_CAP_MEMORY_FAULT_INFO". So I don't see how it is necessary in this series. Whether it's necessary or not for [*], I don't have the answer but we can leave the discussion to that patch series.