kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Ashish Kalra <ashish.kalra@amd.com>
Cc: Vasant Hegde <vasant.hegde@amd.com>,
	pbonzini@redhat.com, tglx@linutronix.de,  mingo@redhat.com,
	bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org,
	 hpa@zytor.com, thomas.lendacky@amd.com, john.allen@amd.com,
	 herbert@gondor.apana.org.au, davem@davemloft.net,
	joro@8bytes.org,  suravee.suthikulpanit@amd.com, will@kernel.org,
	robin.murphy@arm.com,  michael.roth@amd.com,
	dionnaglaze@google.com, nikunj@amd.com, ardb@kernel.org,
	 kevinloughlin@google.com, Neeraj.Upadhyay@amd.com,
	kvm@vger.kernel.org,  linux-kernel@vger.kernel.org,
	linux-crypto@vger.kernel.org,  linux-coco@lists.linux.dev,
	iommu@lists.linux.dev
Subject: Re: [PATCH v3 3/3] x86/sev: Fix broken SNP support with KVM module built-in
Date: Fri, 7 Feb 2025 07:52:58 -0800	[thread overview]
Message-ID: <Z6YsWiTGM___898F@google.com> (raw)
In-Reply-To: <d27f91a9-0dff-4445-8d2f-9db862acd1d0@amd.com>

On Wed, Feb 05, 2025, Ashish Kalra wrote:
> On 2/5/2025 1:31 PM, Sean Christopherson wrote:
> > On Wed, Feb 05, 2025, Vasant Hegde wrote:
> >> So we don't want to clear  CC_ATTR_HOST_SEV_SNP after RMP initialization -OR-
> >> clear for all failures?
> > 
> > I honestly don't know, because the answer largely depends on what happens with
> > hardware.  I asked in an earlier version of this series if IOMMU initialization
> > failure after the RMP is configured is even survivable.
> > 
> 
> As i mentioned earlier and as part of this series and summarizing this again here:

Thanks!

> - snp_rmptable_init() enables SNP support system-wide and that means the HW starts
> doing RMP checks for memory accesses, but as RMP table is zeroed out initially, 
> all memory is configured to be host/HV owned. 
> 
> It is only after SNP_INIT(_EX) that RMP table is configured and initialized with
> HV_Fixed, firmware pages and stuff like IOMMU RMP enforcement is enabled. 
> 
> If the IOMMU initialization fails after IOMMU support on SNP check is completed
> and host SNP is enabled, then SNP_INIT(_EX) will fail as IOMMUs need to be enabled
> for SNP_INIT to succeed.
> 
> > For this series, I think it makes sense to match the existing behavior, unless
> > someone from AMD can definitively state that we should do something different.
> > And the existing behavior is that amd_iommu_snp_en and CC_ATTR_HOST_SEV_SNP will
> > be left set if the IOMMU completes iommu_snp_enable(), and the kernel completes
> > RMP setup.
> 
> Yes, that is true and this behavior is still consistent with this series.
> 
> Again to reiterate, if iommu_snp_enable() and host SNP enablement is successful,
> any late IOMMU initialization failures should cause SNP_INIT to fail and that means
> IOMMU RMP enforcement will never get enabled and RMP table will remain configured
> for all memory marked as HV/host owned. 

So the kernel should be able to limp along, but CC_ATTR_HOST_SEV_SNP will be in
a half-baked state.

Would it make sense to WARN if the RMP has been configured?  E.g. as a follow-up
change:

	/*
	 * SNP platform initilazation requires IOMMUs to be fully configured.
	 * If the RMP has NOT been configured, simply mark SNP as unsupported.
	 * If the RMP is configured, but RMP enforcement has not been enabled
	 * in IOMMUs, then the system is in a half-baked state, but can limp
	 * along as all memory should be Hypervisor-Owned in the RMP.   WARN,
	 * but leave SNP as "supported" to avoid confusing the kernel.
	 */
	if (ret && cc_platform_has(CC_ATTR_HOST_SEV_SNP) &&
	    !WARN_ON_ONCE(amd_iommu_snp_en))
		cc_platform_clear(CC_ATTR_HOST_SEV_SNP);

  reply	other threads:[~2025-02-07 15:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-03 21:56 [PATCH v3 0/3] Fix broken SNP support with KVM module built-in Ashish Kalra
2025-02-03 21:56 ` [PATCH v3 1/3] crypto: ccp: Add external API interface for PSP module initialization Ashish Kalra
2025-02-07 21:45   ` Tom Lendacky
2025-02-08  4:52     ` Kalra, Ashish
2025-02-03 21:56 ` [PATCH v3 2/3] KVM: SVM: Ensure PSP module is initialized if KVM module is built-in Ashish Kalra
2025-02-07 21:46   ` Tom Lendacky
2025-02-03 21:56 ` [PATCH v3 3/3] x86/sev: Fix broken SNP support with KVM module built-in Ashish Kalra
2025-02-05  9:51   ` Vasant Hegde
2025-02-05 15:17     ` Sean Christopherson
2025-02-05 16:55       ` Vasant Hegde
2025-02-05 19:31         ` Sean Christopherson
2025-02-05 22:54           ` Kalra, Ashish
2025-02-07 15:52             ` Sean Christopherson [this message]
2025-02-07 21:45               ` Kalra, Ashish
2025-02-06  5:41           ` Vasant Hegde

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=Z6YsWiTGM___898F@google.com \
    --to=seanjc@google.com \
    --cc=Neeraj.Upadhyay@amd.com \
    --cc=ardb@kernel.org \
    --cc=ashish.kalra@amd.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=dionnaglaze@google.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=hpa@zytor.com \
    --cc=iommu@lists.linux.dev \
    --cc=john.allen@amd.com \
    --cc=joro@8bytes.org \
    --cc=kevinloughlin@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.roth@amd.com \
    --cc=mingo@redhat.com \
    --cc=nikunj@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=robin.murphy@arm.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=vasant.hegde@amd.com \
    --cc=will@kernel.org \
    --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).