From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.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 4B055395D9B for ; Fri, 10 Apr 2026 23:58:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775865526; cv=none; b=su22lNI4LBR9Siiokppy5XodfuT/bU5gmjLYeChwvfAvQJ8L1LjpSxGDxxJx/DQmD2CNXLnSg7qH75Sk+6osiq2pBsa9BcVzN1quZ5NOnS8EvYrCktsCkODNeNN+13FOsxTcFCXmUQkZEgCBN/3KNaIMER8n1PY5h4NHIrvl+tU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775865526; c=relaxed/simple; bh=OAjJXOD9e9ZCrBOE/1IAIYsawrgalTMmndxT6VPcqaI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=pJ1E1VLp/JWNvYpY8lX45lPoA/nxhA7cvhlXifTeXJqUhWuJsuIYTaJqLvQTJzx9G35LgeYd1hsOK6uwumlYGgHimUVMTQyRubfrwmpJRjSdV+XKJOoVr5S8pa55Phi6UiT6eROL0NXb6h1sUsg+5hrFkR8sZN3TA6ViMkZgjCM= 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=ON2v/yDz; arc=none smtp.client-ip=209.85.215.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ON2v/yDz" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-b630b4d8d52so1674606a12.3 for ; Fri, 10 Apr 2026 16:58:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775865525; x=1776470325; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=213w54WPItuluzf2zJbkbNPQu8IYxwh/wCXaJ4qlVE8=; b=ON2v/yDzBCoEKjSF6VuhnBFU5wU8Hg4VAEvF6qLQmkVZhJomSkl1O8DlhK/QK4cvWw JfffFOEviBVu9uL+/qlPWhPdO81Hi4tSG28XrltB75eISo3M7f0zL7BlJVJ2SrRYmS+n w6/ITHz1uyhGqSnQP62PteT+H23pIGuAkqwl3T9licfP1XpzoeGeQq96qzF4tzo2VGU0 rs3V2i5mrcTbGbzf3EjeeCMunSszYnYEM2SsIGexXUhEXcOk/Sv9wI8hmtWK5ByJCRJZ TS0sy/mv+1ybRq3EP1Q343WKlludO4LQq+pV+UdzMMqUjv2Fren1oEyc3wDKLP6jnBaL iYDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775865525; x=1776470325; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=213w54WPItuluzf2zJbkbNPQu8IYxwh/wCXaJ4qlVE8=; b=ag6vXw8X6COQN8g3cLwxIB1eHbReABWH2Kpy3xHs0Y5kDHjhXvLSck7BmCKJHS7RqN 5Q25L3Tri6tgjzOAZ686RMg686KwrcDzPo77jQqzSN+KrWOuycdi6kxq9mtB2zVQycHZ X77gtGbcPRaPkonoXS4Bs40CDFEAORTB87XyaIDNDikXLR3GeUpTIT8vOWv8ZP3afcS5 77yM8g2bx45zhAFF975WmFn8V+mm5B58XD72yGfXzgRUeCF+CRYxMUr+nP+i7ZETcnMN r1svKvSCzuVLIuM0ngHJG72GHxBZo0aOyHUmcE2+hj225wTyknznj9M0Lg3TR5kmUXpf GVDQ== X-Forwarded-Encrypted: i=1; AJvYcCUk0QVpEfQ8ZFdlmGJXazgWpYbKzyQghMsD1TMVRZf05qkVHcIev+UweoY+E03+H0LrWLRzNBkZZg78HuI=@vger.kernel.org X-Gm-Message-State: AOJu0YwHh5Hwo1EQ3j0SOLoO4S78duL9doYl5aMAPtC2dtat90dEsmm6 P69LU1LOI4LJ9/7XxEWzDhmJw8DX4iHJYtnANtIKcaiHQCtVL5Y0W8/v1/XbYhAoEn4HSMdoEZ4 4vVvTiA== X-Received: from pgct9.prod.google.com ([2002:a05:6a02:5289:b0:c73:fc44:8ba7]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:e292:b0:39f:216:f400 with SMTP id adf61e73a8af0-39fe3cd7666mr6101142637.14.1775865524420; Fri, 10 Apr 2026 16:58:44 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 10 Apr 2026 16:58:23 -0700 In-Reply-To: <20260410235832.2312342-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260410235832.2312342-1-seanjc@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260410235832.2312342-5-seanjc@google.com> Subject: [GIT PULL] KVM: x86: Emulated MMIO changes for 7.1 From: Sean Christopherson To: Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson Content-Type: text/plain; charset="UTF-8" Emulated MMIO changes to fix a use-after-free (kernel stack) bug, and do a spring cleaning of the code (though it could certainly use even more cleaning). The following changes since commit 11439c4635edd669ae435eec308f4ab8a0804808: Linux 7.0-rc2 (2026-03-01 15:39:31 -0800) are available in the Git repository at: https://github.com/kvm-x86/linux.git tags/kvm-x86-mmio-7.1 for you to fetch changes up to e2138c4a5be1e50d75281136bdc3e709cb07ec5e: KVM: x86: Add helpers to prepare kvm_run for userspace MMIO exit (2026-03-02 16:06:49 -0800) ---------------------------------------------------------------- KVM x86 emulated MMIO changes for 7.1 Copy single-chunk MMIO write values into a persistent (per-fragment) field to fix use-after-free stack bugs due to KVM dereferencing a stack pointer after an exit to userspace. Clean up and comment the emulated MMIO code to try to make it easier to maintain (not necessarily "easy", but "easier"). ---------------------------------------------------------------- Sean Christopherson (14): KVM: x86: Use scratch field in MMIO fragment to hold small write values KVM: x86: Open code handling of completed MMIO reads in emulator_read_write() KVM: x86: Trace unsatisfied MMIO reads on a per-page basis KVM: x86: Use local MMIO fragment variable to clean up emulator_read_write() KVM: x86: Open code read vs. write userspace MMIO exits in emulator_read_write() KVM: x86: Move MMIO write tracing into vcpu_mmio_write() KVM: x86: Harden SEV-ES MMIO against on-stack use-after-free KVM: x86: Dedup kvm_sev_es_mmio_{read,write}() KVM: x86: Consolidate SEV-ES MMIO emulation into a single public API KVM: x86: Bury emulator read/write ops in emulator_{read,write}_emulated() KVM: x86: Fold emulator_write_phys() into write_emulate() KVM: x86: Rename .read_write_emulate() to .read_write_guest() KVM: x86: Don't panic the kernel if completing userspace I/O / MMIO goes sideways KVM: x86: Add helpers to prepare kvm_run for userspace MMIO exit arch/x86/include/asm/kvm_host.h | 3 - arch/x86/kvm/emulate.c | 13 ++ arch/x86/kvm/svm/sev.c | 20 +-- arch/x86/kvm/vmx/tdx.c | 14 +- arch/x86/kvm/x86.c | 287 ++++++++++++++++++---------------------- arch/x86/kvm/x86.h | 32 ++++- include/linux/kvm_host.h | 3 +- 7 files changed, 180 insertions(+), 192 deletions(-)