From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (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 855601E1C2B for ; Mon, 6 Jan 2025 23:49:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736207383; cv=none; b=qDiVPuPPhLY06IpvzphhtzzuF2WyClDI48GA7gopJKHgKTDaaXqJ10Xw0L5NgkvNjR830QsuF71d1uEI4+7Vn2DmnOsPx7q19HvAgkGLxJKc9gNDp0g5Qm7DyTWlixdDTKrwmeN88e8oLQh7kUpjfxD4VY5ft4eKlv+JH55cyQQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736207383; c=relaxed/simple; bh=LeksPA2aHWOWxkjOZmohp5++dprnR2b8TpT1nllhgtA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=rbyHNZIZHvmbqoRRa4BclqcGpTw8vqh0DdmuRfSu/dAsVXv98LfXJqIpsbMQvgggsfcBGEM0pNb/nKCC6MSWQHVjCfcSjhJqMMJ1D11a5AzCc2vwQ6s4PIOBTxQX/+80QjsQWqH0G972WIEgKqx0AaPnmlZUURhZ2079cdxXZYg= 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=TirlTpII; arc=none smtp.client-ip=209.85.214.202 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="TirlTpII" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2163dc0f5dbso186759165ad.2 for ; Mon, 06 Jan 2025 15:49:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736207381; x=1736812181; 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=P8KvKEJrNmwb2uW1NJHV/ldlGxsuuLV7shvQVTGfzPc=; b=TirlTpIImxSKb7Wldh6ZCcPrt9VqWvicuL6CHxla21nKluilpBTPF/F1UV7LLn0p0J 61FwlZwAk/9ssW9P+AaZxS6Wlpkf33Voq7smtVkRE7fiECGbaREjR/MPoOSOeqfnfCRf oG3GnBOzXUzqvzbSe99/0Nceaba+K2Ni2kOBXkkTtWhG2FEre0chKDBoFDhJTZeNKLHi 3sSL2FwLBBXVPqfKZIZUoVVhegTTKlnPlavdMkl1CUK8y/Ao38HOAQyvZgqnh/WATu16 gyPUX7rUBIkPu28ce9kDvy2GK0z5qXVR/fkOW09VsugO++Xq9PX9U5F8nrZSE6wBAX/V ym/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736207381; x=1736812181; 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=P8KvKEJrNmwb2uW1NJHV/ldlGxsuuLV7shvQVTGfzPc=; b=LcagAl0c+pvM4FyyeZFl2jxUN2STbwkwDbnVqE755LB5UQuEBJdOrD8Per3fPTEdRd OXUXtWFQ8g9blkzc3lKedWxdL4WAzlpqnTHEO1Z/lvtPyDscmwbkatpdoKQ6bqoSOMud FEqTuSCMReqLIN2nHdZXSZzcDUnDOhYAt1SliidXDEcnXXh+qlkl9NRZt3dphYs88RPw 9bIINUoqm3eTF+Z/smz8IUtpQN7wwQ9x/t6lJs0TMUtdKRCQUOsZQEtuFDsrsy6njI/B r2+6humAZEUOVV1trr2DCmprwKEb806bh4mHEP0a+rxqybqcEEjkEUbZYCKRB39hYBAw MY7A== X-Forwarded-Encrypted: i=1; AJvYcCU0bHO0aW4rm3sDmISjAeHgr8jcsFO9Cf4zgjkxXhj+6kcOc8l1ybzkCFEP3vlIZqsxbacjsPnhuAMlrGQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzBbEo4ItpNKZa5MAvRuzzjeeaGqKTwgcGdY8atMcQ5Pj9tJtSX Cs3RHXALLheqKCZDRO2Js8a8F1uAkT8kP1hCCL3V4HQYjB4/qkRjOmEGPdu0kYOjgranxdaThga 3hw== X-Google-Smtp-Source: AGHT+IET+V1UyyJB/gcqviFhIXxdjhULmPls+67Q2bSntTN1ooNqI9R4PqjKGEgEJoLJGTnVCIoD7oDU85w= X-Received: from pfbay10.prod.google.com ([2002:a05:6a00:300a:b0:728:f1bf:72ad]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:7187:b0:1e5:f930:c6e8 with SMTP id adf61e73a8af0-1e5f930c7efmr71092337637.4.1736207380808; Mon, 06 Jan 2025 15:49:40 -0800 (PST) Date: Mon, 6 Jan 2025 15:49:39 -0800 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241115084600.12174-1-yan.y.zhao@intel.com> Message-ID: Subject: Re: [PATCH] KVM: x86/mmu: Only zap valid non-mirror roots in kvm_zap_gfn_range() From: Sean Christopherson To: Yan Zhao Cc: Paolo Bonzini , rick.p.edgecombe@intel.com, binbin.wu@linux.intel.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Mon, Dec 23, 2024, Yan Zhao wrote: > On Sun, Dec 22, 2024 at 08:28:56PM +0100, Paolo Bonzini wrote: > > On Fri, Nov 15, 2024 at 9:50=E2=80=AFAM Yan Zhao = wrote: > > > Sean also suggested making the self-snoop feature a hard dependency f= or > > > enabling TDX [2]. > > > > > > That is because > > > - TDX shared EPT is able to reuse the memory type specified in VMX's = code > > > as long as guest MTRRs are not referenced. > > > - KVM does not call kvm_zap_gfn_range() when attaching/detaching > > > non-coherent DMA devices when the CPU have feature self-snoop. [3] > > > > > > However, [3] cannot be guaranteed after commit 9d70f3fec144 ("Revert = "KVM: > > > VMX: Always honor guest PAT on CPUs that support self-snoop"), which = was > > > due to a regression with the bochsdrm driver. > >=20 > > I think we should treat honoring of guest PAT like zap-memslot-only, > > and make it a quirk that TDX disables. Making it a quirk adds a bit of > > complexity, but it documents why the code exists and it makes it easy f= or > > TDX to disable it. Belated +1. Adding a quirk for honoring guest PAT was on my todo list. A = quirk also allows setups that don't provide a Bochs device to honor guest PAT, wh= ich IIRC is needed for virtio-gpu with a non-snooping graphics device. > Thanks! Will do in this way after the new year. Nice! One oddity to keep in mind when documenting the quirk is that KVM al= ways honors guest PAT when running on AMD. :-/