From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (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 DCD573D092F for ; Thu, 14 May 2026 21:53:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778795640; cv=none; b=PqhHycfH1IOsypCC99JzA9/viX8fCqz36Q/uYBR3SbefLnxfGsqzglFbmwOVQptMyaxYI6bA+lWKyIEVsHfvb7C+K3Ehp51NAp1l5qgRA/O4SaQZtCnDitueCLWzuy1t1yFLiEcdFFUUAMEE3lce7cFYd0SEGRkxQkxHmheNUGs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778795640; c=relaxed/simple; bh=h1qTMfKuEFDk+2bv6Vhwh7IxdwliAQW7/9Hv05WYO48=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=jMHGkRUNe5ppYgTTwetGOR4csA8SuoS+YeSr4+9qFCYAdHiYTRNf+NcJvYimbIX6+Xsk960YnWx7WdtiHZ0tvNh37bgc2aGoozoCLcWtIgtY0+6Sk4JEbU/9Jxc97FSLIUAJm0WkdVDG1Z8h3ugRBbBQwM6XnnRccECQ81fHaKU= 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=KBYjegZZ; arc=none smtp.client-ip=209.85.210.202 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="KBYjegZZ" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-82f74bcfb86so8824564b3a.0 for ; Thu, 14 May 2026 14:53:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1778795638; x=1779400438; 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=6BsK2zhxiwWVCIABmK0YYfn1Tg3z/0TREkGbcHGBLTQ=; b=KBYjegZZjVcKIl1uxAOZdD+CjhXJoBmbE7Nk5yax3ptbHhTZYa0GeNgUu3Q1yY/2jL mHmBYVHxt7sEH/QU+/8aN0axwEXs6vMIbvKtcV6WZ+QRKsTjzn+l5uh6AZHtTimubUvl Cd+83QV5ptgGiuBKbmlOMiRqqk8meg2TzVX1DX8mX8x6lyLoDAnVjwPJrJXNV+/SAT8s +zaphDLcv5miqGlqZuGX9/du7AzG/j91mwQKayTqdS/J55YDjTZAr6A6Eje2LxpWa0ZY 5IXSdj25Qg0J8FyoYxClmG13M64ZBJfDwg5GaumQx7stAY8SODwBDU9MkfDNR3MenB93 d3nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778795638; x=1779400438; 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=6BsK2zhxiwWVCIABmK0YYfn1Tg3z/0TREkGbcHGBLTQ=; b=FYoajp7AdhFGjbGwnsRPO5rPpbbB8DJMwbgf9p8hO2dr2opqQWBFVd1UUy4MEbzK6w 4Mw5cYtP/PuxTgW5zxYJZKBG+e/saJ1YTjQwYEyAzxgjw4SzkashGcS0hWu86k9pfDwU YjKrvXGRBIPcQGgL2HtIjh5r2ziba9vuuXt8+RPDlxDSIuGCPeFVrGkRDJEoH12JUICA nE7PDbv5xhdckElxWiIqsNrdrfU+l3HLSgOr4ilqWUIz7bKoqGkILmzvkUs4D2+ksHNo tx+Wl4hixUo9NIozB5Iu7+oFX4jry0qZrhWKVN+x+udc6RcHDwjez9u9wQfAPMrSxKbX 4lJg== X-Forwarded-Encrypted: i=1; AFNElJ+8OMokCpB8eo3FyzWXj5621MVYQ8GwZahlUrk4ajoXk7b2Cxyb7+S0uzATok2oM33J3I/W2jGpLkDCfjo=@vger.kernel.org X-Gm-Message-State: AOJu0Yzv9l2DPDHRm/aBVRgbnf+4tu0EEA0AZvBF949kaW99k4Zis0Vb ydcMkwUqLY+Ac0U/e9cy9Uro2jY1hEYfB6gaAMNTA7bUT6MPBFNntJ1s2r4qoXXxBxqPC3ClBCI 85B8mLQ== X-Received: from pfbly26.prod.google.com ([2002:a05:6a00:759a:b0:82f:a4cc:2fb3]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:2308:b0:827:447f:7dbd with SMTP id d2e1a72fcca58-83f33f28f4dmr1261393b3a.46.1778795638008; Thu, 14 May 2026 14:53:58 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 14 May 2026 14:53:41 -0700 In-Reply-To: <20260514215355.1648463-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: <20260514215355.1648463-1-seanjc@google.com> X-Mailer: git-send-email 2.54.0.563.g4f69b47b94-goog Message-ID: <20260514215355.1648463-2-seanjc@google.com> Subject: [PATCH v2 01/15] KVM: SVM: Truncate INVLPGA address in compatibility mode From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini , Vitaly Kuznetsov , Kiryl Shutsemau , David Woodhouse , Paul Durrant Cc: Dave Hansen , Rick Edgecombe , kvm@vger.kernel.org, x86@kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, Yosry Ahmed , Kai Huang , Binbin Wu Content-Type: text/plain; charset="UTF-8" Check for full 64-bit mode, not just long mode, when truncating the virtual address as part of INVLPGA emulation. Compatibility mode doesn't support 64-bit addressing. Note, the FIXME still applies, e.g. if the guest deliberately targeted EAX while in 64-bit via an address size override. That flaw isn't worth fixing as it would require decoding the code stream, which would open a an entirely different can of worms, and in practice no sane guest would shove garbage into RAX[63:32] and execute INVLPGA. Note #2, VMSAVE, VMLOAD, and VMRUN all suffer from the same architectural flaw of not providing the full linear address in a VMCB exit information field, because, quoting the APM verbatim: the linear address is available directly from the guest rAX register (VMSAVE, VMLOAD, and VMRUN take a physical address, but they're behavior with respect to rAX is otherwise identical). Fixes: bc9eff67fc35 ("KVM: SVM: Use default rAX size for INVLPGA emulation") Reviewed-by: Yosry Ahmed Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index e74fcde6155e..4ad87f8df392 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -2415,7 +2415,7 @@ static int invlpga_interception(struct kvm_vcpu *vcpu) return 1; /* FIXME: Handle an address size prefix. */ - if (!is_long_mode(vcpu)) + if (!is_64_bit_mode(vcpu)) gva = (u32)gva; trace_kvm_invlpga(to_svm(vcpu)->vmcb->save.rip, asid, gva); -- 2.54.0.563.g4f69b47b94-goog