[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 29/49] i386/sev: Don't disable block discarding for SNP
From: |
Daniel P . Berrangé |
Subject: |
Re: [PATCH v3 29/49] i386/sev: Don't disable block discarding for SNP |
Date: |
Wed, 20 Mar 2024 12:33:10 +0000 |
User-agent: |
Mutt/2.2.12 (2023-09-09) |
On Wed, Mar 20, 2024 at 03:39:25AM -0500, Michael Roth wrote:
> SEV/SEV-ES rely on pinned memory to back guest RAM so discarding
> isn't actually possible. With SNP, only guest_memfd pages are used
> for private guest memory, so discarding of shared memory is still
> possible, so only disable discard for SEV/SEV-ES.
>
> Signed-off-by: Michael Roth <michael.roth@amd.com>
> ---
> target/i386/sev.c | 16 ++++++++++++----
> 1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/target/i386/sev.c b/target/i386/sev.c
> index 134e8f7c22..43e6c0172f 100644
> --- a/target/i386/sev.c
> +++ b/target/i386/sev.c
> @@ -888,10 +888,18 @@ static int sev_kvm_init(ConfidentialGuestSupport *cgs,
> Error **errp)
> uint32_t host_cbitpos;
> struct sev_user_data_status status = {};
>
> - ret = ram_block_discard_disable(true);
> - if (ret) {
> - error_report("%s: cannot disable RAM discard", __func__);
> - return -1;
> + /*
> + * SEV/SEV-ES rely on pinned memory to back guest RAM so discarding
> + * isn't actually possible. With SNP, only guest_memfd pages are used
> + * for private guest memory, so discarding of shared memory is still
> + * possible..
> + */
> + if (!sev_snp_enabled()) {
> + ret = ram_block_discard_disable(true);
> + if (ret) {
> + error_report("%s: cannot disable RAM discard", __func__);
> + return -1;
> + }
> }
Pre-existing code bug, but this method must use 'error_setg' to fill
the 'Error **errp' parameter.
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
- Re: [PATCH v3 24/49] target/i386: Add handling for KVM_X86_SNP_VM VM type, (continued)
- [PATCH v3 25/49] i386/sev: Skip RAMBlock notifiers for SNP, Michael Roth, 2024/03/20
- [PATCH v3 26/49] i386/sev: Skip machine-init-done notifiers for SNP, Michael Roth, 2024/03/20
- [PATCH v3 27/49] i386/sev: Set ms->require_guest_memfd for SNP, Michael Roth, 2024/03/20
- [PATCH v3 28/49] i386/sev: Disable SMM for SNP, Michael Roth, 2024/03/20
- [PATCH v3 29/49] i386/sev: Don't disable block discarding for SNP, Michael Roth, 2024/03/20
- Re: [PATCH v3 29/49] i386/sev: Don't disable block discarding for SNP,
Daniel P . Berrangé <=
- [PATCH v3 30/49] i386/cpu: Set SEV-SNP CPUID bit when SNP enabled, Michael Roth, 2024/03/20
- [PATCH v3 02/49] scripts/update-linux-headers: Add setup_data.h to import list, Michael Roth, 2024/03/20
- [PATCH v3 31/49] i386/sev: Update query-sev QAPI format to handle SEV-SNP, Michael Roth, 2024/03/20
- [PATCH v3 32/49] i386/sev: Don't return launch measurements for SEV-SNP guests, Michael Roth, 2024/03/20
- [PATCH v3 33/49] kvm: Make kvm_convert_memory() non-static, Michael Roth, 2024/03/20