Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2038350rwb; Thu, 17 Nov 2022 05:52:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf7EnTmsD5Ya8KCd2M1t3jBdpVcr9VsyTSXy0cvoQHXkKx+Oh3OMmsTov7Dtr7WQcDZJhzVx X-Received: by 2002:a17:906:948c:b0:78d:e869:f328 with SMTP id t12-20020a170906948c00b0078de869f328mr2061368ejx.696.1668693142216; Thu, 17 Nov 2022 05:52:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668693142; cv=none; d=google.com; s=arc-20160816; b=dIsDTHoevANq6QH96+QT6hbqGzrFs8ogms7GrCPyT6ktgG6lY+vIu0xqBTM8DmLNS0 z3NW5a5TK1rlqi/aCFf9zj7ZblLAOw4Hui8LjQ7G3LW388Ds0jbXyD4bL5aLUQYu5h8R kg1m0q0fsaf0e/oSmSyDhkeABnOFdCUK5vUAp4nDq9z9KQ7zTIjbaK2dTw8t96Seb7s9 /DeOTXa+Qzs2DQNW/7mP57o6RtYN4wDs+ER5SdyW+T8b/WqXdKoCVuT4awoHWg8C/z10 zOYLKoF77uw4wMIK1LrlHCef8BGNNJPaY2/3kUeeGs9llsUx8BYOQeauIpOdZpekl2jq I49g== 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:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=/vHVefLIG5ravCWe/RmmCzG+cR9Rgbcqm12blxIpWaE=; b=WZ5CE/gmGYrFQ8ebIscZEmPcXnYJ6tTX0lC6Trqrg5EzhSeijFE1hYqhLPvh+87rTE qKl2HrIw8YphDIQ308B/N6IIWNSmus5IOyjiNF/bivkE45WL6pMnoZb/187jDM7peywN oJNORireRGgpxMqx3EUfEsjpsKf6CyTLK5QyOYDNeu0akZp4s4D6Aj5D+I4guaq+x1e8 nX36IXSPWtzqoRJfb5LN1XzJtdF0q4YO7sAte/NJqTUdJQxs5b26GT57ggdfgYQXhCPJ vus3ozb4S/F4e1IX2OjTsP18x4URxh3g5yn3WtnOgP04X+gabf8qhDS5UMwDdtuP0iDE Sc7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="F0d+/GQ7"; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y2-20020a056402440200b00457205ae2b5si1006625eda.358.2022.11.17.05.51.52; Thu, 17 Nov 2022 05:52:22 -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=@intel.com header.s=Intel header.b="F0d+/GQ7"; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239749AbiKQNrp (ORCPT + 93 others); Thu, 17 Nov 2022 08:47:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240136AbiKQNr0 (ORCPT ); Thu, 17 Nov 2022 08:47:26 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 775D971F29; Thu, 17 Nov 2022 05:47:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668692845; x=1700228845; h=date:from:to:cc:subject:message-id:reply-to:references: mime-version:in-reply-to; bh=Q9f7oXH6jx2XN9/kuSzGlUsyVFF0nM+veoTgLTKHR8Y=; b=F0d+/GQ7xQLj7304vUTKmq+rVu8TfEczUGa/K+2yUL+d/VE7F17EhAiM 6IHHriONQigDxNDz/OHY3i4H1KHUdthM71YWlcS/CKkOd2fdsFxdJ+jzw 29ZYODwvPR8GTiNzzv30Km4bJsd/D+UjmAncVzR9VHXakNK2ipOkKpR52 mmt69hGpf00XZ6VClk/9P87nkvw7WREb7MVUuQcsn04oXo9t0ldHliBNK IT2pq3NaLfooHMAOe0+YTefayNbGxZ6N66toh1Elb5++CSlz6toooMcUT KNZH9WCRMtdYjDQ85iRkSp1YAoc2v/SqIjukXAaHXuA+fzpEoeHl7nuyq A==; X-IronPort-AV: E=McAfee;i="6500,9779,10534"; a="293246760" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="293246760" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 05:47:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10534"; a="670927116" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="670927116" Received: from chaop.bj.intel.com (HELO localhost) ([10.240.193.75]) by orsmga008.jf.intel.com with ESMTP; 17 Nov 2022 05:47:14 -0800 Date: Thu, 17 Nov 2022 21:42:50 +0800 From: Chao Peng To: Sean Christopherson Cc: Andy Lutomirski , 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: <20221117134250.GC422408@chaop.bj.intel.com> Reply-To: Chao Peng 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: X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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 at 06:48:43PM +0000, Sean Christopherson wrote: > 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. Yeah, I can do that. > 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. You mean avoiding bits 0-2, right, bit3 is not so special and can be used for KVM_MEMORY_EXIT_FLAG_PRIVATE. Chao > > 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