Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2302954rbb; Tue, 27 Feb 2024 18:42:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX+TemD/Ti6u4a4mEeJUVruN6U/Vehk5DEXQP8V42bb+o3dc3Rzv+sdXPfRqDj4EiAX/lgh/fZOTU2H4Eb+UMgWkfXyZSy13LHghi/vHQ== X-Google-Smtp-Source: AGHT+IHYkXbVLRh2FPvdk4V2bZWFX6AF+NkOxeRVZ0P85HsQyYvzRy7QPSAdvAEr6Ql9vjRBTJiN X-Received: by 2002:a92:ce0e:0:b0:365:b570:cbbc with SMTP id b14-20020a92ce0e000000b00365b570cbbcmr1440813ilo.10.1709088122137; Tue, 27 Feb 2024 18:42:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709088122; cv=pass; d=google.com; s=arc-20160816; b=A4r1fhrHxt/kDVJIvTgHefjHXZUJAU/TGFYNzKkKXW+xIvRWuKZMO34dcIvcFnl1B7 c0KmECk744f5zM4mVScLA8FK+PXHW+j25Q4kWI6a7wHU6xaTwFBklEMkt0aFodmaemMb yzIlCTdi0+pHatgbrYK9FwU0b2Ks5ymV5QxgMuAUWHeKL071f20hsRVS8e6IT6JMvFd6 PPulbsn4NNv4Oxya/1z7KEErxkmkkfmx9cApbU8bAGg9hG3nEcBBGRrCE2CwP4yOTc8V MRTJdxM+qhyo2zPhsGN3N/fPG9jfovmRgBZlgpXM6B/t025MrtB/m97npLIUSF9n+393 S2Xg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:reply-to:dkim-signature; bh=53SE99VtRIFLP8URa2ZR5LBSPMEfB4F4A0x9UaRfSO4=; fh=x+6hWUYxHZknOLBsd4bSRs+YW/l4T9pjNj26f0mqNno=; b=bgnnhyfRUc3mg2Zc5T3iYMq8Z041KoHbLo+Nr0IuBvdyIUT6Q8s/7Nuv1R/EjdOnxb d2PL4SRXOaIRD4cHGple/qxbFYULxP2pLqWOGdTTXnavggkC4LYSjmjJnYrasDfWnREV 8tUOY0Q/HUh9nMjQqyXPTcR0WHWxQMxztpPEIydAbseIpmKkaS8Bx8O4sHaskXOoFwyx 90phKfhhmMC7L6M/Gd28V69V1TbBd3cVwKyjhI8KyT0AI/DmNe3CLJGk1zZ6XKp5KRs2 dPNqoKZvYG94zlmM+G2jRYY8UtvmwuQeEErrY5/B6jIgJoCLmIOwA6U/UHwsBrf64rKi HtVA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="BXnfxW/5"; 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-84426-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84426-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id f51-20020a056a000b3300b006e3d627f21fsi6401437pfu.270.2024.02.27.18.42.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 18:42:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84426-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="BXnfxW/5"; 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-84426-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84426-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id BA725287D5F for ; Wed, 28 Feb 2024 02:41:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 914341D69D; Wed, 28 Feb 2024 02:41:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="BXnfxW/5" Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.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 5C3181CD24 for ; Wed, 28 Feb 2024 02:41:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709088112; cv=none; b=ZhX28ciAV7H6z2doynU+glv851GmAZtTf5AY8gI6YbWm57JQqjEHOpuuEy1Y0eLpZ8FJskwxd9g5UtijQ6ll1oqPsfHnkxLpw2m/w6k08NXfs/TPHxlEsyx/Qhf5bnCyq2VuCs3L2Rp6NtK9mPbF1h6Win6MqutXg+BUixbTITg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709088112; c=relaxed/simple; bh=fot6IvGX0Wk467Q0o26GAtryVO620eXI+SwQAgkJhw4=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=gyLBmmjeSVIbQhuKn74Xo0c/yLG5p40iab8rTGjPtAgUPRxh2UqKBzjk2OVOeMh9KR2FGRMC6O4k+ZyDSCzUVeApq2/4urqFa9wJ5skxxpvYH1gq/3kUGITLkpen0tUmKHglBI/5VQE/FAsZMNZzuVY0YesjWY81dcPRKbBhnSU= 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=BXnfxW/5; arc=none smtp.client-ip=209.85.210.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-pf1-f201.google.com with SMTP id d2e1a72fcca58-6e43ee3f5e5so3580585b3a.0 for ; Tue, 27 Feb 2024 18:41:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709088110; x=1709692910; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:reply-to:from:to:cc :subject:date:message-id:reply-to; bh=53SE99VtRIFLP8URa2ZR5LBSPMEfB4F4A0x9UaRfSO4=; b=BXnfxW/5Ti/KVtGUF1bYLpxgYQafnUxhSHuXCrBX5jth1S9eBE+7jHTwIHq4L+P0it ZyPcJOxbyxl0J9GHSrsz3c38F2HVtCJR3QBPKIglvTR8aKTmSVGabXIGeRI6LBbTzinX p7KAU9Quw7hK65IsR7/x4Nh3pnieDPK04ZXxGrrtuIYxxOrkBPQIbsLgxYNk8n76JYb4 7s3fJmpxEMFLe4hoqUR5K9+gQGM28AFMxQm+FYzRtj7tLf+7T2GUScOh49znt58R77q7 3q/MIVaUKr14mKCerriQRNwa+8a5wb3GY8dkvYcQB1JS9HM7/j+ulujS5eEdjbrQHq4m Znsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709088110; x=1709692910; h=cc:to:from:subject:message-id:mime-version:date:reply-to :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=53SE99VtRIFLP8URa2ZR5LBSPMEfB4F4A0x9UaRfSO4=; b=vsZjMlayrEH++iA547/y507sTy5aOwGIT7sLAHHhS8bobLVfEOOJ833lb9+haIsqKq b+xK1txHipDw3PY3P1CM7ZlekKi1+jKVFdE04wzfNvLTiw25iXXsyVVZ/RQQjFxWix6Z BuHlwakd6y1QMq4jtTQFzUbJZREyKIAtH86qcs1TGDVz0AvwaFNBLdIwWVYZ16jPfcjF HCUigX7/iyCr/Xrje2v/s+9Bq9anAFLlQgP7MdNvh3AbwyAqMu4gJadX7ktNghKufuXP rTYOamUuqglVCdLL6Mz6wIr0E4OsWNVLRAm6OJdiJK65wZTBvI2nwlbGcdWMyYUBDUlA cjhw== X-Forwarded-Encrypted: i=1; AJvYcCX6hYwUIjH9pmIn7LCjp5MW9xmcfiL0SC+G0XFiwtsdMfDg6IjN0U4lSf6Hop4aRakC6j5M3gcihSZXXibi2pyOuHS59Q+N/jrkwfeW X-Gm-Message-State: AOJu0YwToGtpKKy3KbS2xZmOowXLRQ5t2gVmcRp0SGp47SvGNPtdXpa6 J/BTCkVW2w7NKRsoDCJdFSBUBjWaqe7YV6FGYbU97hNESjG3ydPpcZLgrSuTYjpEiVAc9aS6HF9 Njg== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a00:92a6:b0:6e5:44d3:5865 with SMTP id jw38-20020a056a0092a600b006e544d35865mr136678pfb.2.1709088110637; Tue, 27 Feb 2024 18:41:50 -0800 (PST) Reply-To: Sean Christopherson Date: Tue, 27 Feb 2024 18:41:31 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Message-ID: <20240228024147.41573-1-seanjc@google.com> Subject: [PATCH 00/16] KVM: x86/mmu: Page fault and MMIO cleanups From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Yan Zhao , Isaku Yamahata , Michael Roth , Yu Zhang , Chao Peng , Fuad Tabba , David Matlack Content-Type: text/plain; charset="UTF-8" This is a combination of prep work for TDX and SNP, and a clean up of the page fault path to (hopefully) make it easier to follow the rules for private memory, noslot faults, writes to read-only slots, etc. Paolo, this is the series I mentioned in your TDX/SNP prep work series. Stating the obvious, these KVM: x86/mmu: Pass full 64-bit error code when handling page faults KVM: x86: Move synthetic PFERR_* sanity checks to SVM's #NPF handler are the drop-in replacements. Isaku Yamahata (1): KVM: x86/mmu: Pass full 64-bit error code when handling page faults Sean Christopherson (15): KVM: x86/mmu: Exit to userspace with -EFAULT if private fault hits emulation KVM: x86: Remove separate "bit" defines for page fault error code masks KVM: x86: Define more SEV+ page fault error bits/flags for #NPF KVM: x86/mmu: Use synthetic page fault error code to indicate private faults KVM: x86/mmu: WARN if upper 32 bits of legacy #PF error code are non-zero KVM: x86: Move synthetic PFERR_* sanity checks to SVM's #NPF handler KVM: x86/mmu: WARN and skip MMIO cache on private, reserved page faults KVM: x86/mmu: Move private vs. shared check above slot validity checks KVM: x86/mmu: Don't force emulation of L2 accesses to non-APIC internal slots KVM: x86/mmu: Explicitly disallow private accesses to emulated MMIO KVM: x86/mmu: Move slot checks from __kvm_faultin_pfn() to kvm_faultin_pfn() KVM: x86/mmu: Handle no-slot faults at the beginning of kvm_faultin_pfn() KVM: x86/mmu: Set kvm_page_fault.hva to KVM_HVA_ERR_BAD for "no slot" faults KVM: x86/mmu: Initialize kvm_page_fault's pfn and hva to error values KVM: x86/mmu: Sanity check that __kvm_faultin_pfn() doesn't create noslot pfns arch/x86/include/asm/kvm_host.h | 45 ++++----- arch/x86/kvm/mmu.h | 4 +- arch/x86/kvm/mmu/mmu.c | 159 +++++++++++++++++++------------- arch/x86/kvm/mmu/mmu_internal.h | 24 ++++- arch/x86/kvm/mmu/mmutrace.h | 2 +- arch/x86/kvm/svm/svm.c | 9 ++ 6 files changed, 151 insertions(+), 92 deletions(-) base-commit: ec1e3d33557babed2c2c2c7da6e84293c2f56f58 -- 2.44.0.278.ge034bb2e1d-goog