Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2240466rdf; Mon, 6 Nov 2023 08:25:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IEoLGyJV4sasNs9PRFTw8fRA03OqwGwP9mfhCZnIAyqdTz041XPJBCw8o5oU5PPiLDMudQC X-Received: by 2002:a05:6358:33a1:b0:168:e364:70af with SMTP id i33-20020a05635833a100b00168e36470afmr40412050rwd.25.1699287932578; Mon, 06 Nov 2023 08:25:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699287932; cv=none; d=google.com; s=arc-20160816; b=uJee6EZrnWzvuKHyfVIYU8O6y3GkLQ3c6yz2Kgr0gSn2eQODaHb0MP+oBOZY6jE48S j7J9+ucO2vLVBKOhDrA4SzM+QnAwsxP4DgNpAxen64pxq+J28KLLtQ9gGp1MoRs3fL+v Q8I+4wxZTB10YSmCBGB2suZmIEfgPPYfjzsAMEn1TBrgil0kGZgovFft9a1bElTtigW3 czyE0G8c+jP8yyGw54reyfpU2UY0if9cuBJrb048eFUwWEJa7rLHGxu45OPB6yO+Gwje ZoVHAo/2s5PIgXVjKbBrU7hhoseYrhi5nnJ/NNbZ1nCA2zC2PZLY/N6pZG0VfnBwStrf yxmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=5xnGb8Sp7Bw2ldCk3b7+mm/bKINtcTCgeZ/KDZ+GW64=; fh=/miUcVpYH8nMZuF+OwSqBCUvyHUtCx9XxINkNV+hgqM=; b=Uj3CMOtcs7CVfcqzVHhDy92VZxCAORYSMj6+n2k725JEafgXebnmAgRAub80FEJD97 8eQs7HSS7RbstrbNwePkiuY1rVuB/IbEMqm9dFKvB8a3r6W23Ul0BNoPJjFjcZ3XomtJ I6zqRWQZbjw2D1dG0ATz+wfL5jk5kEyGiIJNC40o9J18K5g6rhsWmYoCxGamd45nuMjQ VIBT6JosGOVWQgNsjMDbKuO46LgO9VYSZK/OLqDgyFgiBlz9AveqSlw70fH9tHTzA7LZ MBKx3lgJRPAYr+v3hVsPC7JNSnTKd52h6jOK3HjTiGrtVGf5rl2zak5GPRT/m9rAPGIx ewdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ySAqN7oF; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id y73-20020a638a4c000000b005bd321a5c47si4820pgd.256.2023.11.06.08.25.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 08:25:32 -0800 (PST) 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=@google.com header.s=20230601 header.b=ySAqN7oF; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id AF44780ACB5F; Mon, 6 Nov 2023 08:25:30 -0800 (PST) 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 S232032AbjKFQZ3 (ORCPT + 99 others); Mon, 6 Nov 2023 11:25:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231830AbjKFQZ1 (ORCPT ); Mon, 6 Nov 2023 11:25:27 -0500 Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A76D191 for ; Mon, 6 Nov 2023 08:25:19 -0800 (PST) Received: by mail-oi1-x229.google.com with SMTP id 5614622812f47-3b2e72fe47fso3001286b6e.1 for ; Mon, 06 Nov 2023 08:25:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1699287918; x=1699892718; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=5xnGb8Sp7Bw2ldCk3b7+mm/bKINtcTCgeZ/KDZ+GW64=; b=ySAqN7oF51WslqTAsZBYQDAR51F5kZ5ot7qgCrPfpSmjVPtcEgBcbD39bwxufl1EcP yPyEG4zpQUveZNdV2zq28oAaZ4TO60traeY1rXtM6K3yhuoBF/0cTRT5MAhSnOUQEfzK ro8+X30m/hTmUYF7liMk6rN9BOpurtlqYQN9v467MdzTk71trnHZZWjAh9Y+Mmd16zyb keVJSJ60oOYsxhas68tyVoruknKeo64lObVhYadQtyrBr7d6H85Mm4+epAkEwnPDKRSH gTU5iiWrVtBODpMqIoHJlDd1kwfyLpfo2hdBzPX8mNpgCgeTMkymuGzO4NpZyvzcs0o7 35DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699287918; x=1699892718; 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=5xnGb8Sp7Bw2ldCk3b7+mm/bKINtcTCgeZ/KDZ+GW64=; b=NXQtcg9+93oUVfL/JFb++h2FFVXVWGVb82BdFtgy2eXAwYY2Lc0NHmvkzrosun5zMU a2D6a4CBHtzH6x/gmHI+Z3kE5fCfr6t2m9AeAxtbgt+UGT0XJROVxOe3eZf0T7Sh+DqY Va3MoDJArn1tyBvyNUmipHALOuKwWD/+FSO3Jrth/8RCkiXMvn1uBAM8p95OzX//b7mI gIEQCnpj9iWRwVRIDpECox+ktdSaGLE5XVt6ksopHYb0lxLRV0PYEcNjTzlf9QMB9/8v rlIlGEVhtx0LBxN4d9Die2QGQQJb6EmPVkdritJf0cWNzAvHz9KrH4GK2vLhPdFTEL/U jQYQ== X-Gm-Message-State: AOJu0YwQDo+pVyuBav5RyXvi8uh5MEDLthCt3XXaisMKuyppn+F7QlqW 9KGcaMMk7RatAwXiykCEExkKdeYaGQrALfSvVgEagg== X-Received: by 2002:a05:6808:28c:b0:3af:a107:cf68 with SMTP id z12-20020a056808028c00b003afa107cf68mr28980109oic.40.1699287918292; Mon, 06 Nov 2023 08:25:18 -0800 (PST) MIME-Version: 1.0 References: <20231105163040.14904-1-pbonzini@redhat.com> <20231105163040.14904-26-pbonzini@redhat.com> In-Reply-To: From: Fuad Tabba Date: Mon, 6 Nov 2023 16:24:42 +0000 Message-ID: Subject: Re: [PATCH 25/34] KVM: selftests: Add helpers to convert guest memory b/w private and shared To: Sean Christopherson Cc: Paolo Bonzini , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Viro , Christian Brauner , "Matthew Wilcox (Oracle)" , Andrew Morton , 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-kernel@vger.kernel.org, Xiaoyao Li , Xu Yilun , Chao Peng , Jarkko Sakkinen , Anish Moorthy , David Matlack , Yu Zhang , Isaku Yamahata , =?UTF-8?B?TWlja2HDq2wgU2FsYcO8bg==?= , Vlastimil Babka , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A. Shutemov" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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]); Mon, 06 Nov 2023 08:25:30 -0800 (PST) On Mon, Nov 6, 2023 at 4:13=E2=80=AFPM Sean Christopherson wrote: > > On Mon, Nov 06, 2023, Fuad Tabba wrote: > > On Sun, Nov 5, 2023 at 4:34=E2=80=AFPM Paolo Bonzini wrote: > > > +void vm_guest_mem_fallocate(struct kvm_vm *vm, uint64_t base, uint64= _t size, > > > + bool punch_hole) > > > +{ > > > + const int mode =3D FALLOC_FL_KEEP_SIZE | (punch_hole ? FALLOC= _FL_PUNCH_HOLE : 0); > > > + struct userspace_mem_region *region; > > > + uint64_t end =3D base + size; > > > + uint64_t gpa, len; > > > + off_t fd_offset; > > > + int ret; > > > + > > > + for (gpa =3D base; gpa < end; gpa +=3D len) { > > > + uint64_t offset; > > > + > > > + region =3D userspace_mem_region_find(vm, gpa, gpa); > > > + TEST_ASSERT(region && region->region.flags & KVM_MEM_= GUEST_MEMFD, > > > + "Private memory region not found for GPA = 0x%lx", gpa); > > > + > > > + offset =3D (gpa - region->region.guest_phys_addr); > > > > nit: why the parentheses? > > I simply forgot to remove them when I changed the function to support spa= nning > multiple memslots, i.e. when the code went from this > > fd_offset =3D region->region.gmem_offset + > (gpa - region->region.guest_phys_addr); > > to what you see above. I wasn't actually expecting an answer, but I literally _did_ ask for it :) Thanks, /fuad