Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp149566lqb; Thu, 14 Mar 2024 07:45:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX8T0RkltHF7vQ1r022lxu5bJhp0sFvryaVn0w+15IQJ47nlg8MrhIJ2fn7GTaJOGoSdhm4YcvxJkoPZZ3q+0JscU27pytMKEmYEVoeJg== X-Google-Smtp-Source: AGHT+IFI7XtOw2aWrVrcrQMPYBqv0HWjHEEnvW3bEHOnGNw3SoaFH3vzBSUJCukz8CFxDSSF7QZg X-Received: by 2002:a0c:e8c6:0:b0:690:f57c:b65c with SMTP id m6-20020a0ce8c6000000b00690f57cb65cmr1970035qvo.23.1710427554710; Thu, 14 Mar 2024 07:45:54 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id e14-20020a0562140d8e00b0068fe057717fsi762764qve.139.2024.03.14.07.45.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 07:45:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103430-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20230601 header.b=AJzgJGq+; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-103430-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103430-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=REJECT sp=REJECT dis=REJECT) 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 63E181C20EA9 for ; Thu, 14 Mar 2024 14:45:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B420470CC4; Thu, 14 Mar 2024 14:45:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="AJzgJGq+" 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 402896FE02 for ; Thu, 14 Mar 2024 14:45:45 +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=1710427546; cv=none; b=Y2aU50Rkb7hs3qvLBqRE9NwGhMszi5hG585lk2fgUUygmR6WjHqZWL7wTbRcL3tV4r4bCb+vqyO0bD8YDmb4thBtdYNDL6V1qbvYTu1sqdoJVNRl2WdagElt5Jm/QJbc0TV//9mLZtXLR+/UJ8RgMujlhztyTznopPJYQdibTds= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710427546; c=relaxed/simple; bh=BwYbNtMX4PnyM344LqBkdMRm1pxVcNQYFxGRXHYxk3E=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=N7FVxzJzeFO68SVwCUV6V59wia1g5mXPwyh45KU6Co+e46tlym8BTbVoxMetdygVmCOTtxP/mdZ0Lp5paHu5IrzXLrN7aWVnF44PKO5WurgV6BKGu5y3I2/c6PL/wmheILDpdqQbCdb4U0cR9/ybt3ZnR+px1EhiPGeJfUUts3k= 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=AJzgJGq+; 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-60cc8d4e1a4so16493627b3.3 for ; Thu, 14 Mar 2024 07:45:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1710427544; x=1711032344; 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=N/k6WMtb7RwOB5cuqYeM7NcbURLzoglqZlXeN+xJ3W4=; b=AJzgJGq+sodS6b/dJnXcgoCtxeSWEaha+AEyIc8B8sI5XqJsqBIKlYLp5USkdTFXfc IG+en119/6KI3k3j3tapMgSdgPuAE/P0Zsk7deroiMxXO3agDirF5Lc7F2Z5DZ+ta3/3 FeP9nze9VngBHH6314/AmzmJrTnAEtrm4WcjM9fjnPXawMw4z6YVCr7P+SmnUDS04YwT uJcIu7mUk9nYBnGCugDDx8C+ejnfLB6gyBflE097wm6OCTU4gSe0t2Z5RO0aKKZrCIG0 yhfBRPDDSH8p81RJIUHV4cCyB3NTwv1ibjZJQXhO+bODvNNzJV5WLqYvo0fn+CMqK17D EYOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710427544; x=1711032344; 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=N/k6WMtb7RwOB5cuqYeM7NcbURLzoglqZlXeN+xJ3W4=; b=PoePsMnO9F2ClwHgnxm+xXQ5588GXBC4aUepsZSaZH0d7rUmSbsnClq5SBW3S0CDVd G6HnE9mUGYNLXo7tclleuKbvswFmW2jx13BFNH5YE/5LzqUkREb6oftVa/JRVjf5TDWL RGuAUL/x9A64zPvrVN9SOGhQiZRaGrT+N5YUMM0WKJIQt7THPzBzg0c3iaElcXJLimCS zMBNtm/gsSP2LTQOUlNE6QUWlXkT2rswHjUAgT7e0NdMTpodF/V3dWCVrA+21v+0A0J9 vKEep/lgN9gOBh/ue5+oeRASygsH5Q3/PrGsHeZMQ63S+gQxjwu04ZRQXy384qdhvIdj uSmA== X-Forwarded-Encrypted: i=1; AJvYcCUGlTMalr1d3FfBmzpQswbluMgsXWvZxzIEuKtB4y8B4Db/PS9zTJ958imFrJ7aJSDOKTIapJCQowq5v2uB8QdxzHpcS6KyIC0d4pk/ X-Gm-Message-State: AOJu0YwnAINEO5oGNSwxxR+VcDN+8DNqY57iRJMHzrK1D7GjvjfCm6vu wrYG8qvBmn8rdbPsW3v5y+zxGduVm20knIST1Lpx35Un7PSF1Mr9byqt7mjXNhNwn2CoFMEIusL 0SQ== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:2848:b0:dcf:b5b8:f825 with SMTP id ee8-20020a056902284800b00dcfb5b8f825mr550085ybb.0.1710427544358; Thu, 14 Mar 2024 07:45:44 -0700 (PDT) Date: Thu, 14 Mar 2024 07:45:42 -0700 In-Reply-To: <985fd7f8-f8dd-4ce4-aa07-7e47728e3ebd@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <0b109bc4-ee4c-4f13-996f-b89fbee09c0b@amd.com> <9e604f99-5b63-44d7-8476-00859dae1dc4@amd.com> <93df19f9-6dab-41fc-bbcd-b108e52ff50b@amd.com> <985fd7f8-f8dd-4ce4-aa07-7e47728e3ebd@amd.com> Message-ID: Subject: Re: [PATCH v11 0/8] KVM: allow mapping non-refcounted pages From: Sean Christopherson To: "Christian =?utf-8?B?S8O2bmln?=" Cc: David Stevens , Christoph Hellwig , Paolo Bonzini , Yu Zhang , Isaku Yamahata , Zhi Wang , Maxim Levitsky , kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Thu, Mar 14, 2024, Christian K=C3=B6nig wrote: > Am 14.03.24 um 12:31 schrieb David Stevens: > > On Thu, Mar 14, 2024 at 6:20=E2=80=AFPM Christian K=C3=B6nig wrote: > > > > > > > > Well as far as I can see Christoph rejects the complexity c= oming with the > > > > > > > > approach of sometimes grabbing the reference and sometimes = not. > > > > > > > Unless I've wildly misread multiple threads, that is not Chri= stoph's objection. > > > > > > > From v9 (https://lore.kernel.org/all/ZRpiXsm7X6BFAU%2Fy@in= fradead.org): > > > > > > >=20 > > > > > > > On Sun, Oct 1, 2023 at 11:25=E2=80=AFPM Christoph Hellwi= g wrote: > > > > > > > > > > > > > > > > On Fri, Sep 29, 2023 at 09:06:34AM -0700, Sean Christo= pherson wrote: > > > > > > > > > KVM needs to be aware of non-refcounted struct page = memory no matter what; see > > > > > > > > > CVE-2021-22543 and, commit f8be156be163 ("KVM: do no= t allow mapping valid but > > > > > > > > > non-reference-counted pages"). I don't think it mak= es any sense whatsoever to > > > > > > > > > remove that code and assume every driver in existenc= e will do the right thing. > > > > > > > > > > > > > > > > Agreed. > > > > > > > > > > > > > > > > > > > > > > > > > > With the cleanups done, playing nice with non-refcou= nted paged instead of outright > > > > > > > > > rejecting them is a wash in terms of lines of code, = complexity, and ongoing > > > > > > > > > maintenance cost. > > > > > > > > > > > > > > > > I tend to strongly disagree with that, though. We can= 't just let these > > > > > > > > non-refcounted pages spread everywhere and instead nee= d to fix their > > > > > > > > usage. > > > > > > And I can only repeat myself that I completely agree with Chris= toph here. > > > > > I am so confused. If you agree with Christoph, why not fix the T= TM allocations? > > > > Because the TTM allocation isn't broken in any way. > > > >=20 > > > > See in some configurations TTM even uses the DMA API for those > > > > allocations and that is actually something Christoph coded. > > > >=20 > > > > What Christoph is really pointing out is that absolutely nobody sho= uld > > > > put non-refcounted pages into a VMA, but again this isn't something > > > > TTM does. What TTM does instead is to work with the PFN and puts th= at > > > > into a VMA. > > > >=20 > > > > It's just that then KVM comes along and converts the PFN back into = a > > > > struct page again and that is essentially what causes all the > > > > problems, including CVE-2021-22543. > > Does Christoph's objection come from my poorly worded cover letter and > > commit messages, then? >=20 > Yes, that could certainly be. >=20 > > Fundamentally, what this series is doing is > > allowing pfns returned by follow_pte to be mapped into KVM's shadow > > MMU without inadvertently translating them into struct pages. >=20 > As far as I can tell that is really the right thing to do. Yes. Christoph, Can you please confirm that you don't object to KVM using follow_pte() to g= et PFNs which happen to have an associated struct page? We've gone in enough = circles...