Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp3012890lqz; Wed, 3 Apr 2024 15:43:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV7hITlPwYr+btRwnZVYlPRzYoVVLDJJn2QtbwjU8ImTfW8UMBx/oOArvfSFBLRWBensV81CJSXdawdletVAD5KhkD9MRs+rWHqVarQlA== X-Google-Smtp-Source: AGHT+IH+QC4J5yrVHS8NEqazabWzJYBUYQ+CNHuAMHmlrgKoWaa+0+AjnLoaquAHrTzUuA+jMZYE X-Received: by 2002:a05:6214:20a4:b0:699:1877:b0fb with SMTP id 4-20020a05621420a400b006991877b0fbmr673726qvd.3.1712184182619; Wed, 03 Apr 2024 15:43:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712184182; cv=pass; d=google.com; s=arc-20160816; b=DO9jelV/Q4Z8yBot665GOaFSCZSXz/IZ3a0VnV6qJUkYgUg/IklXZwxMFcyUvRiIuo xpAwM+DGaA3oqhfiLZgh/iTB7/wtHbtAtBnOynYa4zBl678X6wpUY+K2bZtdvk6JJs+g 9zrXL9PieKTOrbv5PidFMy2/huYmhKu1DjvD7Glm40hGUov8CmKQm/eBYkERLgg6pKZS YtsqF9ET2uIk/u4qmPHHUtV06wZ7M/YC02nsXhjJSKJNDt9/IEeIP8wNgx/JUq/fyrDc zBnX4hBJ5UQ3H//SRCORz5WAIvytBqJ4wcGjGJdCLMGs80ONysD7YZkuMfpwJBbMmnVi MQ7w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=UlLZ7hA4oy1JpChmEiN14ttbq81N4arBdlGQRutmBxA=; fh=VTa/8DWceaDDAcrkc3/6i38FIoVLfEagmdttd2uGUB8=; b=Pzxn6SCnh2vJGOpQ+KqXr8Tq250rsGe/8WpY5skkG66jXwb5gBsoDrUL5kFTz+MO85 ldegWiRfRTa0EYaQTbi/mZThcHFzoXLokoSHU4Dq8U6LmGknyWDsyQcgkSxW5463OBIB jWUdU+flW5wJCPJXSNDFfCXsBUMU7d+/Jp9y9RObOVREnFgj+d7Zw7TpkMvVnn+ggBCt UXEPzxy1CfFV6kovi7JsMTQ+cQIVOn/hUOEHoioRT6J4SvCqujqQWnVgTnf+HpXts6TQ +8FswHyX+U0BPH5hJ+0qss9ZZyJyijFjrLk1dJpSpzEN34lZwDO3+495o4pXiHWCRNuF yscA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=1yFVmDks; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-130696-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130696-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id w7-20020a0cf707000000b00696b34aa028si6861381qvn.75.2024.04.03.15.43.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 15:43:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-130696-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=1yFVmDks; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-130696-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130696-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4507A1C22349 for ; Wed, 3 Apr 2024 22:43:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 61673156965; Wed, 3 Apr 2024 22:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="1yFVmDks" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 019E1153BEF for ; Wed, 3 Apr 2024 22:42:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712184171; cv=none; b=mzbub5fXX+Yi0XpQxzXvGvVxHtmrScWI3ktFlyZCAJUqaGCT4K5WqdzaxA441UO5fRzBKr2QSgPfvj4ySuHLZWParN9C18MIwbaYRSFZYKtamgjqNqdfN8mKiZl2cLvyQ1hjw6V3cIc3ELPebrtr8ocz/nzQ2COQy01hhyQe/YM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712184171; c=relaxed/simple; bh=rz+PvBK3Tkf1uBvQQhw3KfI5Oam7TgqAW+rcHV7DZBA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=JezbFN4XTvG0ZHheCUi8kUJ5TNHOiwdr4jK0NBnFCWpW9w8TQ7JqH+yEV2V5Wz3eV/SguYaPbhKqiWN9Ox/UtPx3Cm4EbkNl64FHCOOxoQ+Gtyt7T5PJW6fKEcwhdmIYQHzfC84vm1w6o2KuijYjFTTg0uNaqdRaiPwTLIU5x50= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=1yFVmDks; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-60cc00203faso7005627b3.2 for ; Wed, 03 Apr 2024 15:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712184169; x=1712788969; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=UlLZ7hA4oy1JpChmEiN14ttbq81N4arBdlGQRutmBxA=; b=1yFVmDkswO93LtyCO4XfV+WN1Koj4ead1qgHwLI8TLYzXRULHUVFQzve7e2de2q9VQ FsP/XnmHnLBayCLs3DbHevSLatcvq8Jw6PYtk5GOmihFXNSPuTeYSkbeTsPVE0GrELrF UOwVhG5Gz/T8+nlW/RQuokl1DWMKufawUGDH7We9YmA4fBmJ8bwbTUo8Ox38PkLbEICs mO2OZ2ZyyONx01tppOktqX08UN/MZcHkWpMK26Yx2g9Q/UYI7qiCw4vAafBC2+GgAb6U nYnG0GvYf1q6ZZfVYBdf2YWMV71q73KaRJPDEnNenwpn3GhV4JFLVzYOJLBb1ACBH2PV 5D+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712184169; x=1712788969; 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=UlLZ7hA4oy1JpChmEiN14ttbq81N4arBdlGQRutmBxA=; b=RsVvLPoraXSq6KbIHa1eaxV0KLRb4U39dYffvUvMX3AArJU1XG9wO4Ip10vX2th3bF dW7+9ePRHztHE8jkHFULm4QoOU3ipk+zqmAvCbF1A+KDJ94SFA3xAl8qLedYGl7e4o3u ZpYNbwpdunaLPTtyR0y+NndudQ4q3ZOiZpx7YbMoq0AyBP79AjaF/FxY+Qytc4eG/oiP uaEpDgP5cuxT68yqB7hC8z4Q+3g9QRSdwyCN3ODFHG5YPrdS5VctEwoqT/kThxlFxHjm X/u403NbrtMQcwg6WTpVVJA3JP1qh3c3F68QSjOgAKkoOuYSGrm3/uHppjMVLvxCV5E6 2pMg== X-Forwarded-Encrypted: i=1; AJvYcCV+z4qw1Kb+RnbGmYb0Aq0V5DoMWhq9L1bXrKCz4XhI3PrQLD4OFWGavtL922+ARa9mfnxpxyCeNmisqm6P7YDQ8aTFdhvu/wHf1mSj X-Gm-Message-State: AOJu0YyJal0vQxtSmLNajfXnRnwHDqa+v0YJQrTAbJx1NezBZqocReDA x1ifMtBAaU+R7TqGX9HRcuasI5kyDDREBx2gH5hsZo1WBByTEZqWzjPz15HAiakcWZaB0e8QZwE idw== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:a195:0:b0:614:fa:c912 with SMTP id y143-20020a81a195000000b0061400fac912mr201614ywg.1.1712184168995; Wed, 03 Apr 2024 15:42:48 -0700 (PDT) Date: Wed, 3 Apr 2024 15:42:47 -0700 In-Reply-To: <20240403220023.GL2444378@ls.amr.corp.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240307020954.GG368614@ls.amr.corp.intel.com> <20240319163309.GG1645738@ls.amr.corp.intel.com> <20240403220023.GL2444378@ls.amr.corp.intel.com> Message-ID: Subject: Re: [RFC PATCH 0/8] KVM: Prepopulate guest memory API From: Sean Christopherson To: Isaku Yamahata Cc: David Matlack , kvm@vger.kernel.org, isaku.yamahata@gmail.com, linux-kernel@vger.kernel.org, Paolo Bonzini , Michael Roth , Federico Parola , isaku.yamahata@linux.intel.com Content-Type: text/plain; charset="us-ascii" On Wed, Apr 03, 2024, Isaku Yamahata wrote: > On Wed, Apr 03, 2024 at 11:30:21AM -0700, > Sean Christopherson wrote: > > > On Tue, Mar 19, 2024, Isaku Yamahata wrote: > > > On Wed, Mar 06, 2024 at 06:09:54PM -0800, > > > Isaku Yamahata wrote: > > > > > > > On Wed, Mar 06, 2024 at 04:53:41PM -0800, > > > > David Matlack wrote: > > > > > > > > > On 2024-03-01 09:28 AM, isaku.yamahata@intel.com wrote: > > > > > > From: Isaku Yamahata > > > > > > > > > > > > Implementation: > > > > > > - x86 KVM MMU > > > > > > In x86 KVM MMU, I chose to use kvm_mmu_do_page_fault(). It's not confined to > > > > > > KVM TDP MMU. We can restrict it to KVM TDP MMU and introduce an optimized > > > > > > version. > > > > > > > > > > Restricting to TDP MMU seems like a good idea. But I'm not quite sure > > > > > how to reliably do that from a vCPU context. Checking for TDP being > > > > > enabled is easy, but what if the vCPU is in guest-mode? > > > > > > > > As you pointed out in other mail, legacy KVM MMU support or guest-mode will be > > > > troublesome. > > > > Why is shadow paging troublesome? I don't see any obvious issues with effectively > > prefetching into a shadow MMU with read fault semantics. It might be pointless > > and wasteful, as the guest PTEs need to be in place, but that's userspace's problem. > > The populating address for shadow paging is GVA, not GPA. I'm not sure if > that's what the user space wants. If it's user-space problem, I'm fine. /facepalm > > Pre-populating is the primary use case, but that could happen if L2 is active, > > e.g. after live migration. > > > > I'm not necessarily opposed to initially adding support only for the TDP MMU, but > > if the delta to also support the shadow MMU is relatively small, my preference > > would be to add the support right away. E.g. to give us confidence that the uAPI > > can work for multiple MMUs, and so that we don't have to write documentation for > > x86 to explain exactly when it's legal to use the ioctl(). > > If we call kvm_mmu.page_fault() without caring of what address will be > populated, I don't see the big difference. Ignore me, I completely spaced that shadow MMUs don't operate on an L1 GPA. I 100% agree that restricting this to TDP, at least for the initial merge, is the way to go. A uAPI where the type of address varies based on the vCPU mode and MMU type would be super ugly, and probably hard to use. At that point, I don't have a strong preference as to whether or not direct legacy/shadow MMUs are supported. That said, I think it can (probably should?) be done in a way where it more or less Just Works, e.g. by having a function hook in "struct kvm_mmu".