Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1049113rwb; Wed, 16 Nov 2022 11:12:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf688N8qbgKT9e3ugrRxSWnH9LPDqV68vrNfGQfoDmtROhtbUxoxsNEVF9wp81CFUaOpBlwy X-Received: by 2002:aa7:cd13:0:b0:45d:2a5:2db8 with SMTP id b19-20020aa7cd13000000b0045d02a52db8mr20205614edw.105.1668625931441; Wed, 16 Nov 2022 11:12:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668625931; cv=none; d=google.com; s=arc-20160816; b=Xf6THWWeCU2IHaABkz+/vXXBQ1XH49iR34DB3/O/ETwMBrWrwb0F/em9OfTUcUapX3 eefBYnS9HOrXQDQIP3fcm/Xr5tN6umi3zkQKBJGBj8tc9/gLOrx1lrS3CHXopfMLe7YJ Ijj/gw1I/GVUf67Xn5qwT0rjmeiLyCwzu1pwF6+C/esKfanfJDP996JlkNKkF7zIdyyp yiFkNp9AgLjhbAah1LHlOq9AgfMbrsUod4+Cy0sJ0sNKoXqB9AlfrI5bDaTR65iBrTsZ p8zVgOVhfMY8fP/NjYENT7EeXr0ufRuuppf0A62q1XE28bwbnK6Ad5rLTq1AHosFSHQQ SC4Q== 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=A0w6P3/5rWNmrPimfeWShNgQxfD7eWOB8psbtgB4eNM=; b=CwTCIBE4ivB6JyBlX8rRg8R4Whdhi31ByrBUeCy9UpIn2J+LBobwrM1hudmCzhLXEr EkP6eODwb0Awzo3ZjVkhHDnrth/db3Ks1Az0VkZp/zzJwtHnogBhxWYOC1TqdKr8/QLI CUCwr1f2n3GlKluH8ZyuCcjewJqJNc6AF/Wc23v3ToZ7o7nnb5APNUTOI8Sgvld+PMUV 3WhAzZOZhKYNXtBwnaWwKk7fa1BrwOGc/ZN83uWBy1lGm4pmaa3ed46IX09o7diI02kA B36o7cTSpsrA7cwC/q//46EOJe6CE6bVlUeWpanm73iBpIBNCgm0GRaX2XVs5YwTxAoB 6Rng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=iuHU2XyS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r19-20020aa7da13000000b00462e7873c10si13228494eds.337.2022.11.16.11.11.50; Wed, 16 Nov 2022 11:12:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=iuHU2XyS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238868AbiKPSvt (ORCPT + 90 others); Wed, 16 Nov 2022 13:51:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232097AbiKPSvH (ORCPT ); Wed, 16 Nov 2022 13:51:07 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEC6A49B50 for ; Wed, 16 Nov 2022 10:48:47 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id v17so17279608plo.1 for ; Wed, 16 Nov 2022 10:48:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=A0w6P3/5rWNmrPimfeWShNgQxfD7eWOB8psbtgB4eNM=; b=iuHU2XySbRBXDBvmb7KGdjsTrJ11MtKm8XUWbJgiH+mJZH0mrNKnmVkYWIqEN8KH+D TMTSgskSxS+dz6pqJQ/6lU5YOrdG2ZlIZWDOaRJRiQwsbQA3PrerGAmObwm4ynhLdSAK ipQyS23YgpxwcwZ6vh4k2Bq/MDUW0MakaENRTi4n4z7trqezhQAU1VBvvRliz6hMutEA 9nByJ3f7EiBHZeDsD30/pNhrYplPoCDi15C49ph/4Z5Ug6emFwiauN/3keUjTSc8xjjS 9rhI8o2gCdwKZQMaSLBrQFcQ5PC0p5wqf3PICwkpXgJE4dUBiCSgdG/Zg1bcsS/uJXqa 0yLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=A0w6P3/5rWNmrPimfeWShNgQxfD7eWOB8psbtgB4eNM=; b=Xvpy0V+yjeQE6rBv8ny8z0DRfqbcj5k+R5BEWUN3UWwOXoCAtKpWwlVZBkn9K5mBy3 GL2/eIb5xxgoUsgPr8RTH5Cus8Z0auYsZ/qpQ+Drw3pbgvEQ3pYWEDpz8oVh/PVu6E4O zEo4t2JxVFx3VTBtTNdeHEzvBD6kYAJvnSOTH+nL5j/NtZ9mKNR9FdCIGs+lo2mJMKQH RCRaJpRsHejXcaBxH0NpxPi9cIg+2hr4QNhvt8aQrCcJ8CfPIVkSMgmvXnPCUtufH0dz H76nwOzFNPs4RB8iMxCxdB0PAIMTxZY54FkT/DQ9sfmBoBBwm0AI+NTt27f4WRDHrs2L 9hIg== X-Gm-Message-State: ANoB5plUTd8EownJ4CvyRfPyqLre6TCfaYhSCElw1wylsV1do95uelJy DLSb3QI/IbIugHbroLzX2dyQ0g== X-Received: by 2002:a17:90b:3c0d:b0:20d:478a:9d75 with SMTP id pb13-20020a17090b3c0d00b0020d478a9d75mr5030085pjb.149.1668624527166; Wed, 16 Nov 2022 10:48:47 -0800 (PST) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id 7-20020a621507000000b0056c0b98617esm11265827pfv.0.2022.11.16.10.48.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 10:48:46 -0800 (PST) Date: Wed, 16 Nov 2022 18:48:43 +0000 From: Sean Christopherson To: Andy Lutomirski Cc: Chao Peng , kvm list , Linux Kernel Mailing List , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, Linux API , linux-doc@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 , the arch/x86 maintainers , "H. Peter Anvin" , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Shuah Khan , Mike Rapoport , Steven Price , "Maciej S . Szmigiero" , Vlastimil Babka , Vishal Annapurve , Yu Zhang , "Kirill A. Shutemov" , "Nakajima, Jun" , Dave Hansen , Andi Kleen , David Hildenbrand , aarcange@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, Quentin Perret , Fuad Tabba , Michael Roth , Michal Hocko , Muchun Song , Wei W Wang Subject: Re: [PATCH v9 3/8] KVM: Add KVM_EXIT_MEMORY_FAULT exit Message-ID: References: <20221025151344.3784230-1-chao.p.peng@linux.intel.com> <20221025151344.3784230-4-chao.p.peng@linux.intel.com> <2e252f4f-7d45-42ac-a88f-fa8045fe3748@app.fastmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2e252f4f-7d45-42ac-a88f-fa8045fe3748@app.fastmail.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 On Wed, Nov 16, 2022, Andy Lutomirski wrote: > > > On Tue, Oct 25, 2022, at 8:13 AM, Chao Peng wrote: > > diff --git a/Documentation/virt/kvm/api.rst > > b/Documentation/virt/kvm/api.rst > > index f3fa75649a78..975688912b8c 100644 > > --- a/Documentation/virt/kvm/api.rst > > +++ b/Documentation/virt/kvm/api.rst > > @@ -6537,6 +6537,29 @@ 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_FAULT */ > > + struct { > > + #define KVM_MEMORY_EXIT_FLAG_PRIVATE (1 << 0) > > + __u32 flags; > > + __u32 padding; > > + __u64 gpa; > > + __u64 size; > > + } memory; > > + > > Would it make sense to also have a field for the access type (read, write, > execute, etc)? I realize that shared <-> private conversion doesn't strictly > need this, but it seems like it could be useful for logging failures and also > for avoiding a second immediate fault if the type gets converted but doesn't > have the right protection yet. I don't think a separate field is necessary, that info can be conveyed via flags. Though maybe we should go straight to a u64 for flags. Hmm, and maybe avoid bits 0-3 so that if/when RWX info is conveyed the flags can align with PROT_{READ,WRITE,EXEC} and the EPT flags, e.g. KVM_MEMORY_EXIT_FLAG_READ (1 << 0) KVM_MEMORY_EXIT_FLAG_WRITE (1 << 1) KVM_MEMORY_EXIT_FLAG_EXECUTE (1 << 2) > (Obviously, if this were changed, KVM would need the ability to report that > it doesn't actually know the mode.) > > --Andy