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

/* SPDX-License-Identifier: GPL-2.0 */
/*
 * AMD SEV header common between the guest and the hypervisor.
 *
 * Author: Brijesh Singh <[email protected]>
 */

#ifndef __ASM_X86_SEV_COMMON_H
#define __ASM_X86_SEV_COMMON_H

#define GHCB_MSR_INFO_POS
#define GHCB_DATA_LOW
#define GHCB_MSR_INFO_MASK

#define GHCB_DATA(v)

/* SEV Information Request/Response */
#define GHCB_MSR_SEV_INFO_RESP
#define GHCB_MSR_SEV_INFO_REQ

#define GHCB_MSR_SEV_INFO(_max, _min, _cbit)

#define GHCB_MSR_INFO(v)
#define GHCB_MSR_PROTO_MAX(v)
#define GHCB_MSR_PROTO_MIN(v)

/* CPUID Request/Response */
#define GHCB_MSR_CPUID_REQ
#define GHCB_MSR_CPUID_RESP
#define GHCB_MSR_CPUID_FUNC_POS
#define GHCB_MSR_CPUID_FUNC_MASK
#define GHCB_MSR_CPUID_VALUE_POS
#define GHCB_MSR_CPUID_VALUE_MASK
#define GHCB_MSR_CPUID_REG_POS
#define GHCB_MSR_CPUID_REG_MASK
#define GHCB_CPUID_REQ_EAX
#define GHCB_CPUID_REQ_EBX
#define GHCB_CPUID_REQ_ECX
#define GHCB_CPUID_REQ_EDX
#define GHCB_CPUID_REQ(fn, reg)

/* AP Reset Hold */
#define GHCB_MSR_AP_RESET_HOLD_REQ
#define GHCB_MSR_AP_RESET_HOLD_RESP
#define GHCB_MSR_AP_RESET_HOLD_RESULT_POS
#define GHCB_MSR_AP_RESET_HOLD_RESULT_MASK

/* Preferred GHCB GPA Request */
#define GHCB_MSR_PREF_GPA_REQ
#define GHCB_MSR_GPA_VALUE_POS
#define GHCB_MSR_GPA_VALUE_MASK

#define GHCB_MSR_PREF_GPA_RESP
#define GHCB_MSR_PREF_GPA_NONE

/* GHCB GPA Register */
#define GHCB_MSR_REG_GPA_REQ
#define GHCB_MSR_REG_GPA_REQ_VAL(v)

#define GHCB_MSR_REG_GPA_RESP
#define GHCB_MSR_REG_GPA_RESP_VAL(v)

/*
 * SNP Page State Change Operation
 *
 * GHCBData[55:52] - Page operation:
 *   0x0001	Page assignment, Private
 *   0x0002	Page assignment, Shared
 */
enum psc_op {};

#define GHCB_MSR_PSC_REQ
#define GHCB_MSR_PSC_REQ_GFN(gfn, op)

#define GHCB_MSR_PSC_REQ_TO_GFN(msr)
#define GHCB_MSR_PSC_REQ_TO_OP(msr)

#define GHCB_MSR_PSC_RESP
#define GHCB_MSR_PSC_RESP_VAL(val)

/* Set highest bit as a generic error response */
#define GHCB_MSR_PSC_RESP_ERROR

/* GHCB Run at VMPL Request/Response */
#define GHCB_MSR_VMPL_REQ
#define GHCB_MSR_VMPL_REQ_LEVEL(v)

#define GHCB_MSR_VMPL_RESP
#define GHCB_MSR_VMPL_RESP_VAL(v)

/* GHCB Hypervisor Feature Request/Response */
#define GHCB_MSR_HV_FT_REQ
#define GHCB_MSR_HV_FT_RESP
#define GHCB_MSR_HV_FT_POS
#define GHCB_MSR_HV_FT_MASK
#define GHCB_MSR_HV_FT_RESP_VAL(v)

#define GHCB_HV_FT_SNP
#define GHCB_HV_FT_SNP_AP_CREATION
#define GHCB_HV_FT_SNP_MULTI_VMPL

/*
 * SNP Page State Change NAE event
 *   The VMGEXIT_PSC_MAX_ENTRY determines the size of the PSC structure, which
 *   is a local stack variable in set_pages_state(). Do not increase this value
 *   without evaluating the impact to stack usage.
 *
 *   Use VMGEXIT_PSC_MAX_COUNT in cases where the actual GHCB-defined max value
 *   is needed, such as when processing GHCB requests on the hypervisor side.
 */
#define VMGEXIT_PSC_MAX_ENTRY
#define VMGEXIT_PSC_MAX_COUNT

#define VMGEXIT_PSC_ERROR_GENERIC
#define VMGEXIT_PSC_ERROR_INVALID_HDR
#define VMGEXIT_PSC_ERROR_INVALID_ENTRY

#define VMGEXIT_PSC_OP_PRIVATE
#define VMGEXIT_PSC_OP_SHARED

struct psc_hdr {} __packed;

struct psc_entry {} __packed;

struct snp_psc_desc {} __packed;

#define GHCB_MSR_TERM_REQ
#define GHCB_MSR_TERM_REASON_SET_POS
#define GHCB_MSR_TERM_REASON_SET_MASK
#define GHCB_MSR_TERM_REASON_POS
#define GHCB_MSR_TERM_REASON_MASK

#define GHCB_SEV_TERM_REASON(reason_set, reason_val)

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

/* Linux-specific reason codes (used with reason set 1) */
#define SEV_TERM_SET_LINUX
#define GHCB_TERM_REGISTER
#define GHCB_TERM_PSC
#define GHCB_TERM_PVALIDATE
#define GHCB_TERM_NOT_VMPL0
#define GHCB_TERM_CPUID
#define GHCB_TERM_CPUID_HV
#define GHCB_TERM_SECRETS_PAGE
#define GHCB_TERM_NO_SVSM
#define GHCB_TERM_SVSM_VMPL0
#define GHCB_TERM_SVSM_CAA

#define GHCB_RESP_CODE(v)

/*
 * Error codes related to GHCB input that can be communicated back to the guest
 * by setting the lower 32-bits of the GHCB SW_EXITINFO1 field to 2.
 */
#define GHCB_ERR_NOT_REGISTERED
#define GHCB_ERR_INVALID_USAGE
#define GHCB_ERR_INVALID_SCRATCH_AREA
#define GHCB_ERR_MISSING_INPUT
#define GHCB_ERR_INVALID_INPUT
#define GHCB_ERR_INVALID_EVENT

#endif