Skip to content

Commit 9b093f5

Browse files
committed
Merge tag 'kvm-x86-svm-6.15' of https://github.com/kvm-x86/linux into HEAD
KVM SVM changes for 6.15 - Ensure the PSP driver is initialized when both the PSP and KVM modules are built-in (the initcall framework doesn't handle dependencies). - Use long-term pins when registering encrypted memory regions, so that the pages are migrated out of MIGRATE_CMA/ZONE_MOVABLE and don't lead to excessive fragmentation. - Add macros and helpers for setting GHCB return/error codes. - Add support for Idle HLT interception, which elides interception if the vCPU has a pending, unmasked virtual IRQ when HLT is executed. - Fix a bug in INVPCID emulation where KVM fails to check for a non-canonical address. - Don't attempt VMRUN for SEV-ES+ guests if the vCPU's VMSA is invalid, e.g. because the vCPU was "destroyed" via SNP's AP Creation hypercall. - Reject SNP AP Creation if the requested SEV features for the vCPU don't match the VM's configured set of features. - Misc cleanups
2 parents a24dbf9 + 4e96f01 commit 9b093f5

File tree

7 files changed

+235
-231
lines changed

7 files changed

+235
-231
lines changed

arch/x86/include/asm/cpufeatures.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@
386386
#define X86_FEATURE_V_SPEC_CTRL (15*32+20) /* "v_spec_ctrl" Virtual SPEC_CTRL */
387387
#define X86_FEATURE_VNMI (15*32+25) /* "vnmi" Virtual NMI */
388388
#define X86_FEATURE_SVME_ADDR_CHK (15*32+28) /* SVME addr check */
389+
#define X86_FEATURE_IDLE_HLT (15*32+30) /* IDLE HLT intercept */
389390

390391
/* Intel-defined CPU features, CPUID level 0x00000007:0 (ECX), word 16 */
391392
#define X86_FEATURE_AVX512VBMI (16*32+ 1) /* "avx512vbmi" AVX512 Vector Bit Manipulation instructions*/

arch/x86/include/asm/sev-common.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,16 @@ struct snp_psc_desc {
212212
#define GHCB_RESP_CODE(v) ((v) & GHCB_MSR_INFO_MASK)
213213

214214
/*
215-
* Error codes related to GHCB input that can be communicated back to the guest
216-
* by setting the lower 32-bits of the GHCB SW_EXITINFO1 field to 2.
215+
* GHCB-defined return codes that are communicated back to the guest via
216+
* SW_EXITINFO1.
217+
*/
218+
#define GHCB_HV_RESP_NO_ACTION 0
219+
#define GHCB_HV_RESP_ISSUE_EXCEPTION 1
220+
#define GHCB_HV_RESP_MALFORMED_INPUT 2
221+
222+
/*
223+
* GHCB-defined sub-error codes for malformed input (see above) that are
224+
* communicated back to the guest via SW_EXITINFO2[31:0].
217225
*/
218226
#define GHCB_ERR_NOT_REGISTERED 1
219227
#define GHCB_ERR_INVALID_USAGE 2

arch/x86/include/asm/svm.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ enum {
116116
INTERCEPT_INVPCID,
117117
INTERCEPT_MCOMMIT,
118118
INTERCEPT_TLBSYNC,
119+
INTERCEPT_IDLE_HLT = 166,
119120
};
120121

121122

@@ -290,10 +291,6 @@ static_assert((X2AVIC_MAX_PHYSICAL_ID & AVIC_PHYSICAL_MAX_INDEX_MASK) == X2AVIC_
290291
#define SVM_SEV_FEAT_ALTERNATE_INJECTION BIT(4)
291292
#define SVM_SEV_FEAT_DEBUG_SWAP BIT(5)
292293

293-
#define SVM_SEV_FEAT_INT_INJ_MODES \
294-
(SVM_SEV_FEAT_RESTRICTED_INJECTION | \
295-
SVM_SEV_FEAT_ALTERNATE_INJECTION)
296-
297294
struct vmcb_seg {
298295
u16 selector;
299296
u16 attrib;

arch/x86/include/uapi/asm/svm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
#define SVM_EXIT_CR14_WRITE_TRAP 0x09e
9696
#define SVM_EXIT_CR15_WRITE_TRAP 0x09f
9797
#define SVM_EXIT_INVPCID 0x0a2
98+
#define SVM_EXIT_IDLE_HLT 0x0a6
9899
#define SVM_EXIT_NPF 0x400
99100
#define SVM_EXIT_AVIC_INCOMPLETE_IPI 0x401
100101
#define SVM_EXIT_AVIC_UNACCELERATED_ACCESS 0x402
@@ -224,6 +225,7 @@
224225
{ SVM_EXIT_CR4_WRITE_TRAP, "write_cr4_trap" }, \
225226
{ SVM_EXIT_CR8_WRITE_TRAP, "write_cr8_trap" }, \
226227
{ SVM_EXIT_INVPCID, "invpcid" }, \
228+
{ SVM_EXIT_IDLE_HLT, "idle-halt" }, \
227229
{ SVM_EXIT_NPF, "npf" }, \
228230
{ SVM_EXIT_AVIC_INCOMPLETE_IPI, "avic_incomplete_ipi" }, \
229231
{ SVM_EXIT_AVIC_UNACCELERATED_ACCESS, "avic_unaccelerated_access" }, \

0 commit comments

Comments
 (0)