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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 16C9BEB64DD for ; Sat, 29 Jul 2023 00:04:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=UNBK/uAgciLNlNpGy00IjjM/0voww7Ncv7kr8Y5TdNs=; b=bsLcq7xUAXumhAj+yqmBPvx0sQ FxPNrSEloztk55BBw0pG1h2AH3LCc4IzbOByemZh565Zyss838kwsd7pYbm9UtDvhyQRglnXMkUej +bz/JLpL8XUTe2fNRsHIUbz+mMYCx4sTHLw6f4y2ia6VMrqCDCeFjRLKLUfgJyVFfvQeY06k9e13L VHpttAioDif1LeZzwu7T4gM4flY50U+ibPwDqNZWCMa2/m2a7zhcvha5KqE5AFZrtocszM5ZerYk/ dWzFBsR7hkDHOXuGIkWF6mJ+YH6MXYffgxYtNcwkIGxuooI9q3Tyj4FurIT1X6IL5E7cCYgVqda7x YoF63HzQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qPXQr-005ZR8-02; Sat, 29 Jul 2023 00:03:41 +0000 Received: from mail-pl1-x64a.google.com ([2607:f8b0:4864:20::64a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qPXQn-005ZPQ-0L for linux-arm-kernel@lists.infradead.org; Sat, 29 Jul 2023 00:03:39 +0000 Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1bb982d2572so17187795ad.0 for ; Fri, 28 Jul 2023 17:03:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690589015; x=1691193815; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=rJg9MbukUkeAf25VcBnSvGPEfaUIyqqF94QJU8orhSY=; b=Zp0GOXqU9vAtanM7byzLEY1ZTAuQCQrnfrak1thKcFFHMBCZO/N4KqKDBd5I3kJffW Vh8ovzLtMVpv7R9tgjnJuitRPz0iowTqbSccpqb9sCrit8s8jZkHgE3EKWmaz9/YJybN uhR+1LBQ/EGKFm12kofvmo1N8Or8Mhd5I9QIxgAZxJjUnAncn/OfNQ+xg9V9rSfFrTW5 6+gyXWvxsDfod0XUAEoSS/aCS0HqakbjGuI1/I8BU2Uy6FDW2YJ6LrCVt60GU5GehRX5 3Ug/sPFW2Iawha4cKCkpfEtG9Mwjo7aL2M8Rz65tztUDm7ObzFqkZ6ozvUAWJtziwaLO +gKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690589015; x=1691193815; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rJg9MbukUkeAf25VcBnSvGPEfaUIyqqF94QJU8orhSY=; b=fB6h0x6tH4wAsiCtXUiWg8Mr5WaJt08dofgINHK1+iOknrDqpnGL8cPOTlydduKoBq /TctQVwLngd/EOD6e85yn+i1isk6uVgvWOFLwGqmxFlbZ5wlGCMEbEr01W4+jZEefRGV sOpI/HsHnJK3jXQk/mxFLmMpxkU6e9iWohHWDzkfHsanp7BPtIdK9NjydULYR28UaoeB IYRWlkHsIDUjCqTH52Rc910a7oEbq1uswvufHcaUjfZmDiVHklRJ8C8xvHRneAB3YV9l FxB9MvT8+c3SSlTgFrPtO9PLGHm8nTER9Z8G+8RJ14TpVGAyWPmdyyOGRQz7eEiycI+J q4JQ== X-Gm-Message-State: ABy/qLaGhFTDtI8hD3mJx8lTvmfxhsPNVw2meUgTiYPxrBDAAe/1JqaE ifGnrwjsvx1Zg5TW1XymFn+MsB32ick= X-Google-Smtp-Source: APBJJlGy4rMQGFiWHQC+IuRONPQH0HvvNAt7asJXiFk+bZ/uVjfNOjPYVgrOl+x+eQJGyA+j61wbqvGP0DI= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:c951:b0:1ae:6895:cb96 with SMTP id i17-20020a170902c95100b001ae6895cb96mr12864pla.5.1690589014804; Fri, 28 Jul 2023 17:03:34 -0700 (PDT) Date: Fri, 28 Jul 2023 17:03:33 -0700 In-Reply-To: Mime-Version: 1.0 References: <20230718234512.1690985-1-seanjc@google.com> <20230718234512.1690985-7-seanjc@google.com> Message-ID: Subject: Re: [RFC PATCH v11 06/29] KVM: Introduce KVM_SET_USER_MEMORY_REGION2 From: Sean Christopherson To: Quentin Perret Cc: Paolo Bonzini , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Matthew Wilcox (Oracle)" , Andrew Morton , Paul Moore , James Morris , "Serge E. Hallyn" , 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-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Chao Peng , Fuad Tabba , Jarkko Sakkinen , Yu Zhang , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , Vlastimil Babka , David Hildenbrand , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A . Shutemov" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230728_170337_163926_0FAE1F05 X-CRM114-Status: GOOD ( 18.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jul 28, 2023, Quentin Perret wrote: > On Tuesday 18 Jul 2023 at 16:44:49 (-0700), Sean Christopherson wrote: > > --- a/include/uapi/linux/kvm.h > > +++ b/include/uapi/linux/kvm.h > > @@ -95,6 +95,16 @@ struct kvm_userspace_memory_region { > > __u64 userspace_addr; /* start of the userspace allocated memory */ > > }; > > > > +/* for KVM_SET_USER_MEMORY_REGION2 */ > > +struct kvm_userspace_memory_region2 { > > + __u32 slot; > > + __u32 flags; > > + __u64 guest_phys_addr; > > + __u64 memory_size; > > + __u64 userspace_addr; > > + __u64 pad[16]; > > Should we replace that pad[16] with: > > __u64 size; > > where 'size' is the size of the structure as seen by userspace? This is > used in other UAPIs (see struct sched_attr for example) and is a bit > more robust for future extensions (e.g. an 'old' kernel can correctly > reject a newer version of the struct with additional fields it doesn't > know about if that makes sense, etc). "flags" serves that purpose, i.e. allows userspace to opt-in to having KVM actually consume what is currently just padding. The padding is there mainly to simplify kernel/KVM code, e.g. the number of bytes that KVM needs to copy in is static. But now that I think more on this, I don't know why we didn't just unconditionally bump the size of kvm_userspace_memory_region. We tried to play games with unions and overlays, but that was a mess[*]. KVM would need to do multiple uaccess reads, but that's not a big deal. Am I missing something, or did past us just get too clever and miss the obvious solution? [*] https://lkml.kernel.org/r/Y7xrtf9FCuYRYm1q%40google.com _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel