From: Sean Christopherson <seanjc@google.com>
To: Ashish Kalra <Ashish.Kalra@amd.com>
Cc: pbonzini@redhat.com, tglx@linutronix.de, mingo@redhat.com,
bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com,
herbert@gondor.apana.org.au, x86@kernel.org, john.allen@amd.com,
davem@davemloft.net, thomas.lendacky@amd.com,
michael.roth@amd.com, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org
Subject: Re: [PATCH v2 3/3] x86/sev: Add SEV-SNP CipherTextHiding support
Date: Fri, 11 Oct 2024 09:10:16 -0700 [thread overview]
Message-ID: <ZwlN6F__ls3naxJq@google.com> (raw)
In-Reply-To: <f2b12d3c76b4e40a85da021ee2b7eaeda1dd69f0.1726602374.git.ashish.kalra@amd.com>
On Tue, Sep 17, 2024, Ashish Kalra wrote:
> diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
> index 564daf748293..77900abb1b46 100644
> --- a/drivers/crypto/ccp/sev-dev.c
> +++ b/drivers/crypto/ccp/sev-dev.c
> @@ -73,11 +73,27 @@ static bool psp_init_on_probe = true;
> module_param(psp_init_on_probe, bool, 0444);
> MODULE_PARM_DESC(psp_init_on_probe, " if true, the PSP will be initialized on module init. Else the PSP will be initialized on the first command requiring it");
>
> +static bool cipher_text_hiding = true;
> +module_param(cipher_text_hiding, bool, 0444);
> +MODULE_PARM_DESC(cipher_text_hiding, " if true, the PSP will enable Cipher Text Hiding");
> +
> +static int max_snp_asid;
Why is this a signed int? '0' is used as the magic "no override" value, so there's
no reason to allow a negative value.
> +module_param(max_snp_asid, int, 0444);
> +MODULE_PARM_DESC(max_snp_asid, " override MAX_SNP_ASID for Cipher Text Hiding");
> +
> MODULE_FIRMWARE("amd/amd_sev_fam17h_model0xh.sbin"); /* 1st gen EPYC */
> MODULE_FIRMWARE("amd/amd_sev_fam17h_model3xh.sbin"); /* 2nd gen EPYC */
> MODULE_FIRMWARE("amd/amd_sev_fam19h_model0xh.sbin"); /* 3rd gen EPYC */
> MODULE_FIRMWARE("amd/amd_sev_fam19h_model1xh.sbin"); /* 4th gen EPYC */
>
> +/* Cipher Text Hiding Enabled */
> +bool snp_cipher_text_hiding;
> +EXPORT_SYMBOL(snp_cipher_text_hiding);
> +
> +/* MAX_SNP_ASID */
> +unsigned int snp_max_snp_asid;
> +EXPORT_SYMBOL(snp_max_snp_asid);
There is zero reason to have multiple variables. The module param varaibles
should be the single source of true.
I'm also not entirely sure exporting individual variables is the right interface,
which is another reason why I want to see the entire "refactoring" in one series.
> static bool psp_dead;
> static int psp_timeout;
>
> @@ -1064,6 +1080,38 @@ static void snp_set_hsave_pa(void *arg)
> wrmsrl(MSR_VM_HSAVE_PA, 0);
> }
>
> +static void sev_snp_enable_ciphertext_hiding(struct sev_data_snp_init_ex *data, int *error)
> +{
> + struct psp_device *psp = psp_master;
> + struct sev_device *sev;
> + unsigned int edx;
> +
> + sev = psp->sev_data;
> +
> + /*
> + * Check if CipherTextHiding feature is supported and enabled
> + * in the Platform/BIOS.
> + */
> + if ((sev->feat_info.ecx & SNP_CIPHER_TEXT_HIDING_SUPPORTED) &&
> + sev->snp_plat_status.ciphertext_hiding_cap) {
snp_cipher_text_hiding should be set to %false if CipherTextHiding is unsupported.
I.e. the module params need to reflect reality.
> + /* Retrieve SEV CPUID information */
> + edx = cpuid_edx(0x8000001f);
> + /* Do sanity checks on user-defined MAX_SNP_ASID */
> + if (max_snp_asid >= edx) {
> + dev_info(sev->dev, "max_snp_asid module parameter is not valid, limiting to %d\n",
> + edx - 1);
> + max_snp_asid = edx - 1;
> + }
> + snp_max_snp_asid = max_snp_asid ? : (edx - 1) / 2;
> +
> + snp_cipher_text_hiding = 1;
s/1/true
> + data->ciphertext_hiding_en = 1;
> + data->max_snp_asid = snp_max_snp_asid;
> +
> + dev_dbg(sev->dev, "SEV-SNP CipherTextHiding feature support enabled\n");
> + }
> +}
prev parent reply other threads:[~2024-10-11 16:10 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-17 20:15 [PATCH v2 0/3] Add SEV-SNP CipherTextHiding feature support Ashish Kalra
2024-09-17 20:16 ` [PATCH v2 1/3] crypto: ccp: New bit-field definitions for SNP_PLATFORM_STATUS command Ashish Kalra
2024-10-01 21:40 ` Peter Gonda
2024-10-02 18:52 ` Tom Lendacky
2024-09-17 20:16 ` [PATCH v2 2/3] crypto: ccp: Add support for SNP_FEATURE_INFO command Ashish Kalra
2024-10-02 21:18 ` Tom Lendacky
2024-10-02 21:19 ` Tom Lendacky
2024-10-02 21:40 ` Kalra, Ashish
2024-10-02 21:49 ` Tom Lendacky
2024-09-17 20:16 ` [PATCH v2 3/3] x86/sev: Add SEV-SNP CipherTextHiding support Ashish Kalra
2024-10-02 14:58 ` Peter Gonda
2024-10-02 18:44 ` Kalra, Ashish
2024-10-03 14:04 ` Peter Gonda
2024-10-03 22:09 ` Ashish Kalra
2024-10-11 16:04 ` Sean Christopherson
2024-11-20 3:14 ` Kalra, Ashish
2024-11-20 21:53 ` Sean Christopherson
2024-11-20 23:43 ` Kalra, Ashish
2024-11-21 14:57 ` Kalra, Ashish
2024-11-21 16:56 ` Sean Christopherson
2024-11-21 17:24 ` Tom Lendacky
2024-11-21 17:42 ` Sean Christopherson
2024-11-21 21:00 ` Kalra, Ashish
2024-12-06 22:30 ` Sean Christopherson
2024-12-07 5:21 ` Kalra, Ashish
2024-12-10 1:30 ` Sean Christopherson
2024-12-10 21:32 ` Kalra, Ashish
2024-12-10 22:57 ` Sean Christopherson
2024-12-11 0:48 ` Kalra, Ashish
2024-12-11 1:01 ` Kalra, Ashish
2024-12-12 0:02 ` Kalra, Ashish
2024-10-02 21:46 ` Tom Lendacky
2024-10-02 21:52 ` Tom Lendacky
2024-10-11 16:10 ` Sean Christopherson [this message]
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=ZwlN6F__ls3naxJq@google.com \
--to=seanjc@google.com \
--cc=Ashish.Kalra@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=hpa@zytor.com \
--cc=john.allen@amd.com \
--cc=kvm@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.roth@amd.com \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.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).