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

Source file repositories/reference/linux-study-clean/arch/x86/include/asm/sev-common.h

File Facts

System
Linux kernel
Corpus path
arch/x86/include/asm/sev-common.h
Extension
.h
Size
8130 bytes
Lines
262
Domain
Architecture Layer
Bucket
arch/x86
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

struct psc_hdr {
	u16 cur_entry;
	u16 end_entry;
	u32 reserved;
} __packed;

struct psc_entry {
	u64	cur_page	: 12,
		gfn		: 40,
		operation	: 4,
		pagesize	: 1,
		reserved	: 7;
} __packed;

struct snp_psc_desc {
	struct psc_hdr hdr;
	struct psc_entry entries[VMGEXIT_PSC_MAX_ENTRY];
} __packed;

#define GHCB_MSR_TERM_REQ		0x100
#define GHCB_MSR_TERM_REASON_SET_POS	12
#define GHCB_MSR_TERM_REASON_SET_MASK	0xf
#define GHCB_MSR_TERM_REASON_POS	16
#define GHCB_MSR_TERM_REASON_MASK	0xff

#define GHCB_SEV_TERM_REASON(reason_set, reason_val)	\
	/* GHCBData[15:12] */				\
	(((((u64)reason_set) &  0xf) << 12) |		\
	 /* GHCBData[23:16] */				\
	((((u64)reason_val) & 0xff) << 16))

/* Error codes from reason set 0 */
#define SEV_TERM_SET_GEN		0
#define GHCB_SEV_ES_GEN_REQ		0
#define GHCB_SEV_ES_PROT_UNSUPPORTED	1
#define GHCB_SNP_UNSUPPORTED		2

/* Linux-specific reason codes (used with reason set 1) */
#define SEV_TERM_SET_LINUX		1
#define GHCB_TERM_REGISTER		0	/* GHCB GPA registration failure */
#define GHCB_TERM_PSC			1	/* Page State Change failure */
#define GHCB_TERM_PVALIDATE		2	/* Pvalidate failure */
#define GHCB_TERM_NOT_VMPL0		3	/* SNP guest is not running at VMPL-0 */
#define GHCB_TERM_CPUID			4	/* CPUID-validation failure */
#define GHCB_TERM_CPUID_HV		5	/* CPUID failure during hypervisor fallback */
#define GHCB_TERM_SECRETS_PAGE		6	/* Secrets page failure */
#define GHCB_TERM_NO_SVSM		7	/* SVSM is not advertised in the secrets page */
#define GHCB_TERM_SVSM_VMPL0		8	/* SVSM is present but has set VMPL to 0 */
#define GHCB_TERM_SVSM_CAA		9	/* SVSM is present but CAA is not page aligned */
#define GHCB_TERM_SECURE_TSC		10	/* Secure TSC initialization failed */
#define GHCB_TERM_SVSM_CA_REMAP_FAIL	11	/* SVSM is present but CA could not be remapped */
#define GHCB_TERM_SAVIC_FAIL		12	/* Secure AVIC-specific failure */

#define GHCB_RESP_CODE(v)		((v) & GHCB_MSR_INFO_MASK)

/*
 * GHCB-defined return codes that are communicated back to the guest via
 * SW_EXITINFO1.
 */
#define GHCB_HV_RESP_NO_ACTION		0
#define GHCB_HV_RESP_ISSUE_EXCEPTION	1
#define GHCB_HV_RESP_MALFORMED_INPUT	2

/*
 * GHCB-defined sub-error codes for malformed input (see above) that are
 * communicated back to the guest via SW_EXITINFO2[31:0].
 */
#define GHCB_ERR_NOT_REGISTERED		1
#define GHCB_ERR_INVALID_USAGE		2
#define GHCB_ERR_INVALID_SCRATCH_AREA	3
#define GHCB_ERR_MISSING_INPUT		4
#define GHCB_ERR_INVALID_INPUT		5
#define GHCB_ERR_INVALID_EVENT		6

struct sev_config {
	__u64 debug		: 1,

	      /*
	       * Indicates when the per-CPU GHCB has been created and registered
	       * and thus can be used by the BSP instead of the early boot GHCB.
	       *
	       * For APs, the per-CPU GHCB is created before they are started
	       * and registered upon startup, so this flag can be used globally
	       * for the BSP and APs.
	       */
	      ghcbs_initialized	: 1,

	      /*
	       * Indicates when the per-CPU SVSM CA is to be used instead of the
	       * boot SVSM CA.

Annotation

Implementation Notes