[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241105010558.1266699-1-dionnaglaze@google.com>
Date: Tue, 5 Nov 2024 01:05:47 +0000
From: Dionna Glaze <dionnaglaze@...gle.com>
To: x86@...nel.org, linux-kernel@...r.kernel.org
Cc: Dionna Glaze <dionnaglaze@...gle.com>, Sean Christopherson <seanjc@...gle.com>,
Paolo Bonzini <pbonzini@...hat.com>, Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>, Dave Hansen <dave.hansen@...ux.intel.com>,
Ashish Kalra <ashish.kalra@....com>, Tom Lendacky <thomas.lendacky@....com>,
John Allen <john.allen@....com>, Herbert Xu <herbert@...dor.apana.org.au>,
"David S. Miller" <davem@...emloft.net>, Michael Roth <michael.roth@....com>,
Luis Chamberlain <mcgrof@...nel.org>, Russ Weight <russ.weight@...ux.dev>,
Danilo Krummrich <dakr@...hat.com>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>, Tianfei zhang <tianfei.zhang@...el.com>,
Alexey Kardashevskiy <aik@....com>
Subject: [PATCH v4 0/6] Support SEV firmware hotloading
The SEV-SNP API specifies a command for hotloading the SEV firmware.
when no SEV or SEV-ES guests are running. The firmware hotloading
support is dependent on the firmware_upload API for better ease-of-use,
and to not necessarily require SEV firmware hotloading support when
building the ccp driver.
For safety, there are steps the kernel should take before allowing a
firmware to be committed:
1. Writeback invalidate all.
2. Data fabric flush.
3. All GCTX pages must be updated successfully with SNP_GUEST_STATUS
The snp_context_create function had the possibility to leak GCTX pages,
so the first patch fixes that bug in KVM.
The ccp driver must continue to be unloadable, so the second patch in
this series fixes a cyclic refcount bug in firmware_loader.
The third patch tracks GCTX pages created and bound to ASIDs at the end
of __sev_do_cmd_locked. These pages are necessary to know at firmware
update time since any running VM must have their context pages updated
before the firmware can be committed.
The fourth patch adds SEV_CMD_DOWNLOAD_FIRMWARE_EX support with its
required cache invalidation steps, but without a means of calling it
from user space.
The fifth patch uses the added command from an instantiation of the
firmware_upload API. When the firmware successfully updates, the GCTX
pages are all refreshed. If any single page's update fails, the driver
treats itself as if the firmware were in a bad state and needs an
immediate restore. All commands that are not DOWNLOAD_FIRMWARE_EX will
fail with RESTORE_REQUIRED, similar to SEV FW on older PSP bootloaders.
The sixth patch avoids platform initialization for KVM VM guests when
vm_type is not legacy SEV/SEV-ES.
The KVM_EXIT for requesting certificates on extended guest request is
not part of this patch series. Any such support must be designed with
races between SNP_COMMIT and servicing extended guest requests such that
the REPORTED_TCB in an attestation_report always correctly corresponds
to the certificates returned by the extended guest request handler.
Changes from v3:
- Removed added init_args field since it was duplicative of probe.
- Split ccp change into three changes.
Changes from v2:
- Fix download_firmware_ex struct definition to be the proper size,
and clear to 0 before using. Thanks to Alexey Kardashevskiy.
Changes from v1:
- Fix double-free with incorrect goto label on error.
- checkpatch cleanup.
- firmware_loader comment cleanup and one-use local variable inlining.
CC: Sean Christopherson <seanjc@...gle.com>
CC: Paolo Bonzini <pbonzini@...hat.com>
CC: Thomas Gleixner <tglx@...utronix.de>
CC: Ingo Molnar <mingo@...hat.com>
CC: Borislav Petkov <bp@...en8.de>
CC: Dave Hansen <dave.hansen@...ux.intel.com>
CC: Ashish Kalra <ashish.kalra@....com>
CC: Tom Lendacky <thomas.lendacky@....com>
CC: John Allen <john.allen@....com>
CC: Herbert Xu <herbert@...dor.apana.org.au>
CC: "David S. Miller" <davem@...emloft.net>
CC: Michael Roth <michael.roth@....com>
CC: Luis Chamberlain <mcgrof@...nel.org>
CC: Russ Weight <russ.weight@...ux.dev>
CC: Danilo Krummrich <dakr@...hat.com>
CC: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
CC: "Rafael J. Wysocki" <rafael@...nel.org>
CC: Tianfei zhang <tianfei.zhang@...el.com>
CC: Alexey Kardashevskiy <aik@....com>
Dionna Glaze (6):
kvm: svm: Fix gctx page leak on invalid inputs
firmware_loader: Move module refcounts to allow unloading
crypto: ccp: Track GCTX through sev commands
crypto: ccp: Add DOWNLOAD_FIRMWARE_EX support
crypto: ccp: Use firmware_upload API for SNP firmware
KVM: SVM: Delay legacy platform initialization on SNP
arch/x86/kvm/svm/sev.c | 10 +-
drivers/base/firmware_loader/sysfs_upload.c | 16 +-
drivers/crypto/ccp/Kconfig | 2 +
drivers/crypto/ccp/Makefile | 1 +
drivers/crypto/ccp/sev-dev.c | 83 ++++-
drivers/crypto/ccp/sev-dev.h | 31 ++
drivers/crypto/ccp/sev-fw.c | 330 ++++++++++++++++++++
include/linux/psp-sev.h | 26 ++
include/uapi/linux/psp-sev.h | 5 +
9 files changed, 480 insertions(+), 24 deletions(-)
create mode 100644 drivers/crypto/ccp/sev-fw.c
--
2.47.0.199.ga7371fff76-goog
Powered by blists - more mailing lists