kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Nikolay Borisov <nik.borisov@suse.com>
Cc: Binbin Wu <binbin.wu@linux.intel.com>,
	Jianxiong Gao <jxgao@google.com>,
	 "Borislav Petkov (AMD)" <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	 Dionna Glaze <dionnaglaze@google.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	jgross@suse.com,
	 "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	kvm@vger.kernel.org,  linux-kernel@vger.kernel.org,
	Ingo Molnar <mingo@redhat.com>,
	pbonzini@redhat.com,  Peter Gonda <pgonda@google.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	 Tom Lendacky <thomas.lendacky@amd.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	x86@kernel.org,  Rick Edgecombe <rick.p.edgecombe@intel.com>
Subject: Re: [PATCH 0/2] x86/kvm: Force legacy PCI hole as WB under SNP/TDX
Date: Wed, 23 Jul 2025 07:34:44 -0700	[thread overview]
Message-ID: <aIDzBOmjzveLjhmk@google.com> (raw)
In-Reply-To: <4acfa729-e0ad-4dc7-8958-ececfae8ab80@suse.com>

On Mon, Jul 14, 2025, Nikolay Borisov wrote:
> On 14.07.25 г. 12:06 ч., Binbin Wu wrote:
> > On 7/10/2025 12:54 AM, Jianxiong Gao wrote:
> > > I tested this patch on top of commit 8e690b817e38, however we are
> > > still experiencing the same failure.
> > > 
> > I didn't reproduce the issue with QEMU.
> > After some comparison on how QEMU building the ACPI tables for HPET and
> > TPM,
> > 
> > - For HPET, the HPET range is added as Operation Region:
> >      aml_append(dev,
> >          aml_operation_region("HPTM", AML_SYSTEM_MEMORY,
> > aml_int(HPET_BASE),
> >                               HPET_LEN));
> > 
> > - For TPM, the range is added as 32-Bit Fixed Memory Range:
> >      if (TPM_IS_TIS_ISA(tpm_find())) {
> >          aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
> >                     TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
> >      }
> > 
> > So, in KVM, the code patch of TPM is different from the trace for HPET in
> > the patch https://lore.kernel.org/kvm/20250201005048.657470-3-seanjc@google.com/,
> > HPET will trigger the code path acpi_os_map_iomem(), but TPM doesn't.

Argh, I was looking at the wrong TPM resource when poking through QEMU.  I peeked
at TPM_PPI_ADDR_BASE, which gets an AML_SYSTEM_MEMORY entry, not TPM_TIS_ADDR_BASE.

*sigh*

Note, the HPET is also enumerated as a fixed resource:

    crs = aml_resource_template();
    aml_append(crs, aml_memory32_fixed(HPET_BASE, HPET_LEN, AML_READ_ONLY));
    aml_append(dev, aml_name_decl("_CRS", crs));

If I comment out the AML_SYSTEM_MEMORY entry for HPET, the kernel's auto-mapping
does NOT kick in (the kernel complains about required resources being missing,
but that's expected).  So I'm pretty sure it's the _lack_ of an AML_SYSTEM_MEMORY
entry for TPM TIS in QEMU's ACPI tables that make everything happy

I can't for the life of me suss out exactly what Google's ACPI tables will look
like.  I'll follow-up internally to try and get an answer on that front.

In the meantime, can someone who has reproduced the real issue get backtraces to
confirm or disprove that acpi_os_map_iomem() is trying to map the TPM TIS range
as WB?  E.g. with something like so:

diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c
index 2e7923844afe..6c3c40909ef9 100644
--- a/arch/x86/mm/pat/memtype.c
+++ b/arch/x86/mm/pat/memtype.c
@@ -528,6 +528,9 @@ int memtype_reserve(u64 start, u64 end, enum page_cache_mode req_type,
 
        start = sanitize_phys(start);
 
+       WARN(start == 0xFED40000,
+            "Mapping TPM TIS with req_type = %u\n", req_type);
+
        /*
         * The end address passed into this function is exclusive, but
         * sanitize_phys() expects an inclusive address.
---

  parent reply	other threads:[~2025-07-23 14:34 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-09 16:54 [PATCH 0/2] x86/kvm: Force legacy PCI hole as WB under SNP/TDX Jianxiong Gao
2025-07-14  9:06 ` Binbin Wu
2025-07-14 11:24   ` Nikolay Borisov
2025-07-15  2:53     ` Binbin Wu
2025-07-16  9:51       ` Binbin Wu
2025-07-23 14:34     ` Sean Christopherson [this message]
2025-07-24  3:16       ` Binbin Wu
2025-07-28 15:33         ` Sean Christopherson
2025-07-30  7:34           ` Binbin Wu
2025-08-15 23:55             ` Korakit Seemakhupt
2025-08-18 11:07               ` Binbin Wu
2025-08-20  3:07             ` Vishal Annapurve
2025-08-20 10:03               ` Binbin Wu
2025-08-20 11:13                 ` Binbin Wu
2025-08-20 17:56                   ` Sean Christopherson
2025-08-21  3:30                     ` Binbin Wu
2025-08-21  5:23                       ` Binbin Wu
2025-08-21  6:02                         ` Jürgen Groß
2025-08-21 15:27                         ` Sean Christopherson
2025-08-28  0:07                           ` Sean Christopherson
  -- strict thread matches above, loose matches on Subject: below --
2025-02-01  0:50 Sean Christopherson
2025-02-01 14:25 ` Dionna Amalie Glaze
2025-02-03 18:14 ` Edgecombe, Rick P
2025-02-03 20:33   ` Sean Christopherson
2025-02-03 23:01     ` Edgecombe, Rick P
2025-02-04  0:27       ` Sean Christopherson
2025-02-05  3:51         ` Edgecombe, Rick P
2025-02-05  7:49           ` Xu, Min M
2025-02-10 15:29         ` Binbin Wu
2025-07-08 14:24 ` Nikolay Borisov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aIDzBOmjzveLjhmk@google.com \
    --to=seanjc@google.com \
    --cc=binbin.wu@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=dionnaglaze@google.com \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=jxgao@google.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=nik.borisov@suse.com \
    --cc=pbonzini@redhat.com \
    --cc=pgonda@google.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=vkuznets@redhat.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).