Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp241473pxj; Wed, 23 Jun 2021 21:00:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7awIyZpk62ne9J372I9U91m+Y4DQCj1RfSyUwj6PgurQEjvc/5809xp33Izrgq9Jl1H5m X-Received: by 2002:a02:77d1:: with SMTP id g200mr2785470jac.132.1624507212450; Wed, 23 Jun 2021 21:00:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624507212; cv=none; d=google.com; s=arc-20160816; b=M0tdWERuAcJvNUNgkbBT5xHPK5PtejeebhhYJy/nvxlqix/iAviDHtYmGiTZ16q7g0 6rjVxLAjsGx88TYAW80Jp+nxXtITbFT+A/0gFpTHxt2+e/J1DpGfBZ37KyL7mVh2Jukv 880dRvHD7rxKFKEhtHOQUifU0Nc9L5lEiBzrLxlQr4461GZBZszBAZVCaqRKaODapE36 ATSw8rNePuBt8y81MXB4eBfSlajmmVozCEdmF3qgaWCpdUqO4JzFATURtnKcLueBj/BD zE5dMusIBb8K98oJs+wtLBZOZqukMAYFpR+91/PJTqhdWU7d9BaxzQD3lWwvsqtptpzs IT3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=BxIaFDPbAuZHR6J/S83W0A67K8R9coNY4bId9HsipsE=; b=SzzRLKWzK/PACn0/gwIg6EB7Yfbdi170mlGUp2YaSoHaMlOIcvQSsjb7sw3ugWJPg8 n8hfUdCnzhYvBN0NIXb6QEP8P1zy3/jSrmJ1VTWtNqAQ/y0rh6ceAjAZjT9CZsFGO7XC E1BgfBArL6MztqZ7sN0pzrPaZScbExTtKQRNwqBGHQn0CyJzMDGJ3FzEk6qYy5yM0HMF 9K3aW0JaWJC2tf1pE3EVcZV5iB4YNKNv0muGbtaaiUMzLBZrB7HRpm+se55B2Py+IDeT iE61Riy/qNFQnNNyHPHk0Uk/Y4yb2Sdwm21PbrCSp7AKuOnStY5vAvtPn/uUUvlShb0t V2zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=RBtU16Sc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f13si1840062ila.126.2021.06.23.20.59.59; Wed, 23 Jun 2021 21:00:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=RBtU16Sc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229508AbhFXEBl (ORCPT + 99 others); Thu, 24 Jun 2021 00:01:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbhFXEBh (ORCPT ); Thu, 24 Jun 2021 00:01:37 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A210C06175F for ; Wed, 23 Jun 2021 20:59:18 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id t9so3613100pgn.4 for ; Wed, 23 Jun 2021 20:59:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=BxIaFDPbAuZHR6J/S83W0A67K8R9coNY4bId9HsipsE=; b=RBtU16Scd9URJKreXZFwanEfHJ1XRZJXhO4qEt4uU8YvBtSRsG8M0Msq7z7U3gBGbw UdDX7s8F5odJ8nqB9b8EVGbHLmPHB74/ZvZg8RK4YeZb6UMq7MIYumlvjDcfnL6WHIaV l3qHnUTf57CgLtDUOfr/2EStz1LFXjnziJK6o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=BxIaFDPbAuZHR6J/S83W0A67K8R9coNY4bId9HsipsE=; b=FxyQg+GSen1sSgW9RIL05NZjxdG7UmOReELDLtRBR7HrjGzcxQkSS5u56K4V7T1NyP f026bCvOYxlrlnBPG2AyUrvTQNvZv7TWzTwv098+ZPSgxWWUFSF57HW8dpCjTvgZbOj/ vENU9s9O4MXkW0AS61m9zof1U6IF0XjZRF5kyt/DgL3vr7lOr8NlYJf3dalmwmaOH29m 8uC2x8PS7j1V0Z9A47ba5aLKMlEZ6wGOV+OmO00CeMkqZ9jBGpExyEKLDMK/HfSmBUx/ QnYNDoiZCUqf/EHHa8T5XThTxIlEIACf5cH7oKtCTdbE928CF91xjLWU5yhUylrQWajE Hv4Q== X-Gm-Message-State: AOAM531rZQjwjVFVFtjSjX+FZ7LeddEdF6ujC+vzHGnPDIbLSq1mPSgT SUOBYTwqEFnCvPYIORXDuNkQxg== X-Received: by 2002:aa7:96fc:0:b029:2e9:e827:928f with SMTP id i28-20020aa796fc0000b02902e9e827928fmr2818805pfq.49.1624507157546; Wed, 23 Jun 2021 20:59:17 -0700 (PDT) Received: from localhost ([2401:fa00:8f:203:5038:6344:7f10:3690]) by smtp.gmail.com with UTF8SMTPSA id j15sm1163260pfh.194.2021.06.23.20.59.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Jun 2021 20:59:16 -0700 (PDT) From: David Stevens X-Google-Original-From: David Stevens To: Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Paolo Bonzini , Zhenyu Wang , Zhi Wang Cc: James Morse , Alexandru Elisei , Suzuki K Poulose , Will Deacon , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, David Stevens Subject: [PATCH 0/6] KVM: Remove uses of struct page from x86 and arm64 MMU Date: Thu, 24 Jun 2021 12:57:43 +0900 Message-Id: <20210624035749.4054934-1-stevensd@google.com> X-Mailer: git-send-email 2.32.0.93.g670b81a890-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org KVM supports mapping VM_IO and VM_PFNMAP memory into the guest by using follow_pte in gfn_to_pfn. However, the resolved pfns may not have assoicated struct pages, so they should not be passed to pfn_to_page. This series removes such calls from the x86 and arm64 secondary MMU. To do this, this series modifies gfn_to_pfn to return a struct page in addition to a pfn, if the hva was resolved by gup. This allows the caller to call put_page only when necessated by gup. This series provides a helper function that unwraps the new return type of gfn_to_pfn to provide behavior identical to the old behavior. As I have no hardware to test powerpc/mips changes, the function is used there for minimally invasive changes. Additionally, as gfn_to_page and gfn_to_pfn_cache are not integrated with mmu notifier, they cannot be easily changed over to only use pfns. This addresses CVE-2021-22543 on x86 and arm64. David Stevens (6): KVM: x86/mmu: release audited pfns KVM: mmu: also return page from gfn_to_pfn KVM: x86/mmu: avoid struct page in MMU KVM: arm64/mmu: avoid struct page in MMU KVM: mmu: remove over-aggressive warnings drm/i915/gvt: use gfn_to_pfn's page instead of pfn arch/arm64/kvm/mmu.c | 42 +++++---- arch/mips/kvm/mmu.c | 3 +- arch/powerpc/kvm/book3s.c | 3 +- arch/powerpc/kvm/book3s_64_mmu_hv.c | 5 +- arch/powerpc/kvm/book3s_64_mmu_radix.c | 5 +- arch/powerpc/kvm/book3s_hv_uvmem.c | 4 +- arch/powerpc/kvm/e500_mmu_host.c | 2 +- arch/x86/kvm/mmu/mmu.c | 60 ++++++------ arch/x86/kvm/mmu/mmu_audit.c | 13 ++- arch/x86/kvm/mmu/mmu_internal.h | 3 +- arch/x86/kvm/mmu/paging_tmpl.h | 36 +++++--- arch/x86/kvm/mmu/tdp_mmu.c | 7 +- arch/x86/kvm/mmu/tdp_mmu.h | 4 +- arch/x86/kvm/x86.c | 9 +- drivers/gpu/drm/i915/gvt/gtt.c | 12 ++- drivers/gpu/drm/i915/gvt/hypercall.h | 3 +- drivers/gpu/drm/i915/gvt/kvmgt.c | 12 +-- drivers/gpu/drm/i915/gvt/mpt.h | 8 +- include/linux/kvm_host.h | 27 ++++-- include/linux/kvm_types.h | 5 + virt/kvm/kvm_main.c | 123 +++++++++++++------------ 21 files changed, 212 insertions(+), 174 deletions(-) -- 2.32.0.93.g670b81a890-goog