From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 15F4E26D4F7 for ; Wed, 25 Feb 2026 01:21:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771982473; cv=none; b=Xuz+M5sfJ5tEgfAN6VDvw8mLWkV7qgs2+7+Exd8X0PFlR/KsYmoT2PhD+8T4InhxYRxcdDJhQJpA/pF7uFIC4W6s34dUloIFHyFrXTN4s10Suog1OU8H6XuzrOU3wEmJ8XBNnaeK9B2BfJpUyslk3Qb8tHk8IqQ5E2XgKX4zofw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771982473; c=relaxed/simple; bh=8BpbiNXkNmG68PauqKn1vI4bfavvNUcZL8H/4h/xCDU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=HTMgMstxsVyR3ntimn1Rm0CxRHyvlNsJZpcsH5oKt5+fFhpnOFWTy37C3rDFVFXUKAjbvtSveVCleaj79CULkF9oU8RDrpezUHqm7kfUgrkQ7aTj7io0Wmc+8SH3wTzlNNysg2eCe/+D2dqU2Xp7I/NKK+mTp82tOxoWLK3FQkA= 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=E/S28+Gi; arc=none smtp.client-ip=209.85.216.73 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="E/S28+Gi" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-3568090851aso39449396a91.1 for ; Tue, 24 Feb 2026 17:21:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1771982471; x=1772587271; 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=NC+PweffU72Wb4W/8tySGqQ5rYKiIvlwoGA5HRqPPw0=; b=E/S28+GiKw/h0AgddShLg2kxTtGNWU+SqqePcjI7qhDLWptlTcGOycmmLV0LjriD65 4MHsIEiJ6vAWwM025BjKmgcX1lsGolh4fdfHW30dmZuuRe/1rqQU9LFnAca3NRZh5Go0 cRpXF1t9nSE15ZoJ4sBVoq6UyqjUTthcGR79kv0xT2Y0dPTP1DTpI6FCB5Q+cxMCf2vS zQnC7leasPNY3hCTzDYRspDm1rO6ns07SqlAf4WCAiAvV6XUk+P7KCx/GWGb2rsMthpy +xE0VWCp68HzvW4RWhFgCy40Vy9vpOGx9Ik6D5kUgG8wsMIhZnS5dyGI/8Jf9/1VKtvc 4ZHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771982471; x=1772587271; 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=NC+PweffU72Wb4W/8tySGqQ5rYKiIvlwoGA5HRqPPw0=; b=fCmfIajgWkuXN6dDZxfwODfwmxwnhXCyRpIUUXZppEpkco6UCKpx0sK4YNOO+4i3QL uhXysc4nVS+1NTI+iXctgGX2ABAv2RG5KcXB1Bk3i0U5oSJulk2RAJbaL6VPZt1L3zPJ 2VOMRAQdEIAzEFnVy0GCKMmuSlUmPG4T2K7fidYIzf4/vTm9JpmjUU81RbYsgtjvRMqP ioBDXdh0cQyUH/ZJ8hSLhGmuYWxEkPlHnRjNGU+GYd8P6f0g0c+Qk8DBaiJwBC+Epsxe OZo9rbkuYfemb6yzhkvpRhnrGQg72bKqnOlg7qWDPPsW2XD9Dajp0O/U4q255Z8XfWaA YkFw== X-Forwarded-Encrypted: i=1; AJvYcCXE92gokrYOYUibF7EAsy2HFj3+A0GwA3B1PcclqlS0dcczjx/4ofiYHYZbfVNW6QuG9iArqZlZYODrJ9Q=@vger.kernel.org X-Gm-Message-State: AOJu0YwQWz22QsNKdAwM+PPTPBUrUOMr/Xmddkx5Gf8Tp/xiSvHz7yWZ HUFA84WmkTqokN4jeY2sMKh78cK5WH2mVd/SUSHFegADquLs6GfuvJUx12VYIPIknaij0BGv1Sr qF+ckMg== X-Received: from pjbev14.prod.google.com ([2002:a17:90a:eace:b0:356:3104:ed7]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:4ec5:b0:343:7714:4ca8 with SMTP id 98e67ed59e1d1-3590f08c0e8mr548523a91.15.1771982471453; Tue, 24 Feb 2026 17:21:11 -0800 (PST) Reply-To: Sean Christopherson Date: Tue, 24 Feb 2026 17:20:45 -0800 In-Reply-To: <20260225012049.920665-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: <20260225012049.920665-1-seanjc@google.com> X-Mailer: git-send-email 2.53.0.414.gf7e9f6c205-goog Message-ID: <20260225012049.920665-11-seanjc@google.com> Subject: [PATCH 10/14] KVM: x86: Bury emulator read/write ops in emulator_{read,write}_emulated() From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini , Kiryl Shutsemau Cc: kvm@vger.kernel.org, x86@kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, Yashu Zhang , Rick Edgecombe , Binbin Wu , Xiaoyao Li , Tom Lendacky , Michael Roth Content-Type: text/plain; charset="UTF-8" Now that SEV-ES invokes vcpu_mmio_{read,write}() directly, bury the read vs. write emulator ops in the dedicated emulator callbacks so that they are colocated with their usage, and to make it harder for non-emulator code to use hooks that are intended for the emulator. Opportunistically rename the structures to get rid of the long-standing "emultor" typo. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 022e953906f7..5fb5259c208f 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -8134,17 +8134,6 @@ static int write_emulate(struct kvm_vcpu *vcpu, gpa_t gpa, return emulator_write_phys(vcpu, gpa, val, bytes); } -static const struct read_write_emulator_ops read_emultor = { - .read_write_emulate = read_emulate, - .read_write_mmio = vcpu_mmio_read, -}; - -static const struct read_write_emulator_ops write_emultor = { - .read_write_emulate = write_emulate, - .read_write_mmio = vcpu_mmio_write, - .write = true, -}; - static int emulator_read_write_onepage(unsigned long addr, void *val, unsigned int bytes, struct x86_exception *exception, @@ -8295,8 +8284,13 @@ static int emulator_read_emulated(struct x86_emulate_ctxt *ctxt, unsigned int bytes, struct x86_exception *exception) { - return emulator_read_write(ctxt, addr, val, bytes, - exception, &read_emultor); + static const struct read_write_emulator_ops ops = { + .read_write_emulate = read_emulate, + .read_write_mmio = vcpu_mmio_read, + .write = false, + }; + + return emulator_read_write(ctxt, addr, val, bytes, exception, &ops); } static int emulator_write_emulated(struct x86_emulate_ctxt *ctxt, @@ -8305,8 +8299,13 @@ static int emulator_write_emulated(struct x86_emulate_ctxt *ctxt, unsigned int bytes, struct x86_exception *exception) { - return emulator_read_write(ctxt, addr, (void *)val, bytes, - exception, &write_emultor); + static const struct read_write_emulator_ops ops = { + .read_write_emulate = write_emulate, + .read_write_mmio = vcpu_mmio_write, + .write = true, + }; + + return emulator_read_write(ctxt, addr, (void *)val, bytes, exception, &ops); } #define emulator_try_cmpxchg_user(t, ptr, old, new) \ -- 2.53.0.414.gf7e9f6c205-goog