From nobody Mon Feb 9 00:54:01 2026 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 A3D99192B94 for ; Fri, 9 Aug 2024 19:03:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723230221; cv=none; b=TlTcnRt02q/69sjl0KSX/JoVojzh8BncWLlq9ynwD2TmznFcMXQ4vBXDElxdnkc44Wm8HwWwuBHIdg6l0MD40yW6pRcpXM67fdDiiRdZQSlnJZBJtSp/TqbVU/PlHGjkK2W+SKKXp2zbSR1BJyZnf+ZfHa9ZGkcJeAPIeBIy4xU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723230221; c=relaxed/simple; bh=sRrTbOJcfiSrIsMETnqBjIT3jUMPYwkaFHnukschxi8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Jd5doONuV2ZwYRy6Y07uXpG28q3MjPuSMEFXmszZxMUd5DXgK13tzTanyp8zlQBLbgoLVvqLg3aVlRNZXo6vwqq8Q6tXIJA7t4JbgG39h0Awfj8v1blQJkA9BY0pfqDzyRs6HBwINTMyE8Qj8X2zyn1Cxno5nUGprhvlNWdoW3I= 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=sbnrb9ZM; arc=none smtp.client-ip=209.85.216.74 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="sbnrb9ZM" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2d1bc2352e1so2313176a91.0 for ; Fri, 09 Aug 2024 12:03:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723230220; x=1723835020; 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=Dmb967qkQZW0D4SkRpUMqgdJRb4TcheZ9woSO8g40qM=; b=sbnrb9ZMAfulI93tmzCOU+a/I/BhuB3dybTTWS2Zgl4v8ppUHlGs9IYAjb2DXXQVw0 7e+V+xCtv84Ms2c/WZBrbwE7Fe/Uu6lNHh05lOCCaO9qp6xffRdtedkzjW8iyNZQ+19F sxdM+BugfmxiNkoKvnLOFeHupznER39PGd+Y74g+d9xjDLo7IvqR/1eYAmEuUpivZRla nSSc8jqQKsUcaMC/2ykHk+M7CCEZLwbbbzLPZ4Gqxm493diqQ4D7rfSR8C56NtQUnvzq g48BuEKfhJUWyqnZ/4T26yk2IDHynii2RVRyRkDz8kGjPuNGfRcTFvRcZU4MmcRdETAb gUdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723230220; x=1723835020; 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=Dmb967qkQZW0D4SkRpUMqgdJRb4TcheZ9woSO8g40qM=; b=G4HHSyL3Z9/TzRegRphikXN3aD2HRjvvlGDryD8ZXgtPFKMlwacDA0niypiraayklJ Hx1N1aioxS++fIZ4uEObV0OlFGErCAp0YVLd3ni2HwXL236rD0dujpYgZbbqXNA0kltQ x86TUm474I1XQNuZHBG8P5Ygmi/wk+Z1+oJHVW6yzdwm1YW3aTigiZiN9tEKy1+//l/T YNvKbzoXfgWkwlGXHryru5i7gtb2p7ZEZn/CZP4ZV0jbqO9O5Oqbjv8VAr+fnwdy9kHJ nTL+OUj4hvRClrTVVArujkCvVHeLWtC7WA+2n2CoAf84XcQdxZE0KPEIvj7W14HrlF4a nsQA== X-Forwarded-Encrypted: i=1; AJvYcCXKaryK5bPt8QrEkaVXUY1W6Isgif2qt8HldWxAD/O7cHZ7HziXf6CHMVSf1UvYVzKJTyYfzGm4fYM/SBH3j7dKDhYJZpIUq2GTW3EP X-Gm-Message-State: AOJu0Yx6Efj/IznKdsmjGdFoxm6yZA9sWQeIZk9L68DcpRMETwNtKO+3 XXf/UK5ILojtGNh/o9Sir1V3H/2Zi8u1F0NwWdIfFwPq4/GitaPkW57G8Y4rmgIq+ugK/PrIgix 0FA== X-Google-Smtp-Source: AGHT+IGV4VVBAjWqDuf8M8TDt3Ik+GDvR+wC8XLlmWU8kgrPMhiCKChR2E/SCFm3L0IlV7VJrRflltDSgTc= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:90a:114f:b0:2d0:11a1:8013 with SMTP id 98e67ed59e1d1-2d1c4c2e3cbmr42172a91.2.1723230219818; Fri, 09 Aug 2024 12:03:39 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 9 Aug 2024 12:03:04 -0700 In-Reply-To: <20240809190319.1710470-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: <20240809190319.1710470-1-seanjc@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Message-ID: <20240809190319.1710470-8-seanjc@google.com> Subject: [PATCH 07/22] KVM: x86: Store gpa as gpa_t, not unsigned long, when unprotecting for retry From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Gonda , Michael Roth , Vishal Annapurve , Ackerly Tng Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Store the gpa used to unprotect the faulting gfn for retry as a gpa_t, not an unsigned long. This fixes a bug where 32-bit KVM would unprotect and retry the wrong gfn if the gpa had bits 63:32!=3D0. In practice, this bug is functionally benign, as unprotecting the wrong gfn is purely a performance issue (thanks to the anti-infinite-loop logic). And of course, almost no one runs 32-bit KVM these days. Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 372ed3842732..4c3493ffce0b 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -8934,7 +8934,8 @@ static bool retry_instruction(struct x86_emulate_ctxt= *ctxt, gpa_t cr2_or_gpa, int emulation_type) { struct kvm_vcpu *vcpu =3D emul_to_vcpu(ctxt); - unsigned long last_retry_eip, last_retry_addr, gpa =3D cr2_or_gpa; + unsigned long last_retry_eip, last_retry_addr; + gpa_t gpa =3D cr2_or_gpa; =20 last_retry_eip =3D vcpu->arch.last_retry_eip; last_retry_addr =3D vcpu->arch.last_retry_addr; --=20 2.46.0.76.ge559c4bf1a-goog