Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2232177rdf; Mon, 6 Nov 2023 08:13:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IF6eXOkqADvN7F0cEzeWaW/mCFShGpeEWT2mepJ7hFWKwVPdCehOvU5/eoQGJ2KP5iJRQ4s X-Received: by 2002:a05:6a20:12c2:b0:16b:c62d:876 with SMTP id v2-20020a056a2012c200b0016bc62d0876mr28383250pzg.23.1699287215463; Mon, 06 Nov 2023 08:13:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699287215; cv=none; d=google.com; s=arc-20160816; b=y9uaTVV+lp30U+O35QbT3Tp3ExPoOCBjhwE4NARAQtZnLlyObO2T4iDmbEwTm5HY7D kI9B2zQbJ6pz9tLsW7kkG6T19Y2sdMleZXElX2l54RCzXFKBFxBiZsmqhRa//qkEVwqa uzCHa17Npqu7YS/UzwR71Q/u7LRX2HKW4z0s/bVkq9PW9ncaIHXUWIPdE2wUti+9xdye upwOFDiAd/0QxpcV8++jsk0atWjoXWATdFNvhEp2mQviSrgYI2+7gzLda8326msUeZwK 2hm5ywloJcgNeWXOWP+qBL7kGAW7uck9pR8LFr5QED9OFW+v/sKmPJRxJD9bUUCO4R9n slgw== 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:from:subject :message-id:references:mime-version:in-reply-to:date:dkim-signature; bh=mmoUoGnC/t23H3IPxV2qsT2AAyd7sUSE5gGiJgJlDX0=; fh=P5PSl5+yGLC/mg6/A51ivzu5Y/AooYK7zXVJ7WfYZMk=; b=gEW/x+srFa24v/KJQReRy0goMSIPkU3oFf8jt32PNAKQuDhlPRHaCw9EGqlTAbujjT V8fZiyaLIHjf/pDB1NcgSsK9WHPAQFMh4LJlSIc1NKbKrFOYMa4Hk91cNSVACVDPc4Fa N9Hh7uX1hKeEs3ZY9pGdEvD4wQICu/1F7aPeyLwq5CI5bGyL00hQvGvz5OUlqEJde4BF pfhkVHZ6e3yw3ppbVHlVb/wjxTMw3gvoF+japZRgeMRAIokXGxzQXDC4NXzCVVfDVzHf yHzgXfGeSMqeiouvz6huHkk0RaISHchG+4B+CpsjTynJ/HpvGkf6g4e30uHXY5UP3j+w v5Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Oe1xs7MQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id bv3-20020a632e03000000b005ac2d06099esi7888173pgb.478.2023.11.06.08.13.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 08:13:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Oe1xs7MQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id E057B8052BC7; Mon, 6 Nov 2023 08:13:32 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232239AbjKFQNK (ORCPT + 99 others); Mon, 6 Nov 2023 11:13:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229642AbjKFQNG (ORCPT ); Mon, 6 Nov 2023 11:13:06 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBBC91BC for ; Mon, 6 Nov 2023 08:13:03 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5a7cf717bacso63996067b3.1 for ; Mon, 06 Nov 2023 08:13:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1699287183; x=1699891983; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=mmoUoGnC/t23H3IPxV2qsT2AAyd7sUSE5gGiJgJlDX0=; b=Oe1xs7MQxbs5oPRVpc1SJfxw+zaBXWx0tAzWWUfGeY0ZnxLo3TUCZUwSHoYrsLcen+ 0T98De4h1V0jyIRipVTcdvrBJ3Gf6ahV4xyT5pGJZOMVm2tQZItGID1uzEtmhh/aG+xd iN5yBgGbHR5grM6zMLTpWxCSPRcfeObuMhPxbVqdGo94SCvbVIL/p7EHqsDDYVZS7oux 38cAa3a5BNG2BF/RGEaagKWyzMT3MhudxuLj0b7sjmXHkLqn1bXVwZoG0xgvZmFfzo6o qOXxpsu4IIKS84P9O1shcP+44+bOV0AFRJXACHqrQAZ8unbvgtfM8pN2zOg6LTUiLAxB P8KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699287183; x=1699891983; h=content-transfer-encoding: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=mmoUoGnC/t23H3IPxV2qsT2AAyd7sUSE5gGiJgJlDX0=; b=HhLXA2+StoAxBx/50fz5r5fmSUkJLjx68IHPBXj0scHiZ3a/pYVwRgLGu/IQlS/MXK sh2Mk9KHTt0nqwUxLI9J2gGfFeakr07l4IWF8A0neyr0jf0dKRzWohQt4j7+l/Zh6HKc kAG+YSLLwCHZbWcDY6CjEAtBLp1o+WCo2CCdadKNkCb1vPXmXid0SazeAFALIVpzL2No 7f+cSNy9BfDbfBts2Exg/Vr1K9DIVLJs4uLFW2KhbFW7oma6i/3EpQwpBBtYDSXI8KOO UavQPxzxqogYgmWNEr39KD86ES5N+O+tVzhgxXfsz8q56uqdpqS5JJpADiQG/RqgUF3M mswg== X-Gm-Message-State: AOJu0Yxxh3xGFvbs5IPvcCU81vJaUVQ1tQguq3l612Jwql4ndT/G2Wqj LSN3crot1KNJVuCe9V8alMYeFibNA7c= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a0d:d5d2:0:b0:5a7:ad67:b4b6 with SMTP id x201-20020a0dd5d2000000b005a7ad67b4b6mr228755ywd.2.1699287183068; Mon, 06 Nov 2023 08:13:03 -0800 (PST) Date: Mon, 6 Nov 2023 08:13:01 -0800 In-Reply-To: Mime-Version: 1.0 References: <20231105163040.14904-1-pbonzini@redhat.com> <20231105163040.14904-26-pbonzini@redhat.com> Message-ID: Subject: Re: [PATCH 25/34] KVM: selftests: Add helpers to convert guest memory b/w private and shared From: Sean Christopherson To: Fuad Tabba 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?Q?Micka=C3=ABl_Sala=C3=BCn?=" , 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=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Mon, 06 Nov 2023 08:13:33 -0800 (PST) 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_F= L_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_GU= EST_MEMFD, > > + "Private memory region not found for GPA 0x= %lx", gpa); > > + > > + offset =3D (gpa - region->region.guest_phys_addr); >=20 > nit: why the parentheses? I simply forgot to remove them when I changed the function to support spann= ing 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.