mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-17 15:38:00 +00:00
runtime: make SNP guest policy configurable
Dependening on the platform configuration, users might want to set a more secure policy than the QEMU default. Signed-off-by: Paul Meyer <katexochen0@gmail.com>
This commit is contained in:
parent
9379a18c8a
commit
5635410dd3
@ -62,8 +62,9 @@ valid_hypervisor_paths = @QEMUSNPVALIDHYPERVISORPATHS@
|
||||
|
||||
# SNP 'ID Block' and 'ID Authentication Information Structure'.
|
||||
# If one of snp_id_block or snp_id_auth is specified, the other must be specified, too.
|
||||
# Notice that the default SNP policy of QEMU (0x30000) is used by Kata, and the IDBlock
|
||||
# must be generated with exactly this policy.
|
||||
# Notice that the default SNP policy of QEMU (0x30000) is used by Kata, if not explicitly
|
||||
# set via 'snp_guest_policy' option. The IDBlock contains the guest policy as field, and
|
||||
# it must match the value from 'snp_guest_policy' or, if unset, the QEMU default policy.
|
||||
#
|
||||
# 96-byte, base64-encoded blob to provide the ‘ID Block’ structure for the
|
||||
# SNP_LAUNCH_FINISH command defined in the SEV-SNP firmware ABI (QEMU default: all-zero)
|
||||
@ -72,6 +73,13 @@ valid_hypervisor_paths = @QEMUSNPVALIDHYPERVISORPATHS@
|
||||
# for the SNP_LAUNCH_FINISH command defined in the SEV-SNP firmware ABI (QEMU default: all-zero)
|
||||
#snp_id_auth = ""
|
||||
|
||||
# SNP Guest Policy, the ‘POLICY’ parameter to the SNP_LAUNCH_START command.
|
||||
# If unset, the QEMU default policy (0x30000) will be used.
|
||||
# Notice that the guest policy is enforced at VM launch, and your pod VMs
|
||||
# won't start at all if the policy denys it. This will be indicated by a
|
||||
# 'SNP_LAUNCH_START' error.
|
||||
#snp_guest_policy = 196608
|
||||
|
||||
# Optional space-separated list of options to pass to the guest kernel.
|
||||
# For example, use `kernel_params = "vsyscall=emulate"` if you are having
|
||||
# trouble running pre-2.15 glibc.
|
||||
|
@ -62,8 +62,9 @@ valid_hypervisor_paths = @QEMUVALIDHYPERVISORPATHS@
|
||||
|
||||
# SNP 'ID Block' and 'ID Authentication Information Structure'.
|
||||
# If one of snp_id_block or snp_id_auth is specified, the other must be specified, too.
|
||||
# Notice that the default SNP policy of QEMU (0x30000) is used by Kata, and the IDBlock
|
||||
# must be generated with exactly this policy.
|
||||
# Notice that the default SNP policy of QEMU (0x30000) is used by Kata, if not explicitly
|
||||
# set via 'snp_guest_policy' option. The IDBlock contains the guest policy as field, and
|
||||
# it must match the value from 'snp_guest_policy' or, if unset, the QEMU default policy.
|
||||
#
|
||||
# 96-byte, base64-encoded blob to provide the ‘ID Block’ structure for the
|
||||
# SNP_LAUNCH_FINISH command defined in the SEV-SNP firmware ABI (QEMU default: all-zero)
|
||||
@ -72,6 +73,13 @@ valid_hypervisor_paths = @QEMUVALIDHYPERVISORPATHS@
|
||||
# for the SNP_LAUNCH_FINISH command defined in the SEV-SNP firmware ABI (QEMU default: all-zero)
|
||||
#snp_id_auth = ""
|
||||
|
||||
# SNP Guest Policy, the ‘POLICY’ parameter to the SNP_LAUNCH_START command.
|
||||
# If unset, the QEMU default policy (0x30000) will be used.
|
||||
# Notice that the guest policy is enforced at VM launch, and your pod VMs
|
||||
# won't start at all if the policy denys it. This will be indicated by a
|
||||
# 'SNP_LAUNCH_START' error.
|
||||
#snp_guest_policy = 196608
|
||||
|
||||
# Optional space-separated list of options to pass to the guest kernel.
|
||||
# For example, use `kernel_params = "vsyscall=emulate"` if you are having
|
||||
# trouble running pre-2.15 glibc.
|
||||
|
@ -330,6 +330,9 @@ type Object struct {
|
||||
// for the SNP_LAUNCH_FINISH command defined in the SEV-SNP firmware ABI (default: all-zero)
|
||||
SnpIdAuth string
|
||||
|
||||
// SnpGuestPolicy is the integer representation of the SEV-SNP guest policy.
|
||||
SnpGuestPolicy *uint64
|
||||
|
||||
// Raw byte slice of initdata digest
|
||||
InitdataDigest []byte
|
||||
}
|
||||
@ -415,6 +418,9 @@ func (object Object) QemuParams(config *Config) []string {
|
||||
if object.SnpIdAuth != "" {
|
||||
objectParams = append(objectParams, fmt.Sprintf("id-auth=%s", object.SnpIdAuth))
|
||||
}
|
||||
if object.SnpGuestPolicy != nil {
|
||||
objectParams = append(objectParams, fmt.Sprintf("policy=%d", *object.SnpGuestPolicy))
|
||||
}
|
||||
if len(object.InitdataDigest) > 0 {
|
||||
// due to https://github.com/confidential-containers/qemu/blob/amd-snp-202402240000/qapi/qom.json#L926-L929
|
||||
// hostdata in SEV-SNP should be exactly 32 bytes
|
||||
|
@ -109,6 +109,7 @@ type hypervisor struct {
|
||||
RemoteHypervisorSocket string `toml:"remote_hypervisor_socket"`
|
||||
SnpIdBlock string `toml:"snp_id_block"`
|
||||
SnpIdAuth string `toml:"snp_id_auth"`
|
||||
SnpGuestPolicy *uint64 `toml:"snp_guest_policy"`
|
||||
HypervisorPathList []string `toml:"valid_hypervisor_paths"`
|
||||
JailerPathList []string `toml:"valid_jailer_paths"`
|
||||
VirtioFSDaemonList []string `toml:"valid_virtio_fs_daemon_paths"`
|
||||
@ -992,6 +993,7 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
|
||||
ExtraMonitorSocket: extraMonitorSocket,
|
||||
SnpIdBlock: h.SnpIdBlock,
|
||||
SnpIdAuth: h.SnpIdAuth,
|
||||
SnpGuestPolicy: h.SnpGuestPolicy,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -473,6 +473,9 @@ type HypervisorConfig struct {
|
||||
// for the SNP_LAUNCH_FINISH command defined in the SEV-SNP firmware ABI (default: all-zero)
|
||||
SnpIdAuth string
|
||||
|
||||
// SnpGuestPolicy is the integer representation of the SEV-SNP guest policy.
|
||||
SnpGuestPolicy *uint64
|
||||
|
||||
// KernelParams are additional guest kernel parameters.
|
||||
KernelParams []Param
|
||||
|
||||
|
@ -38,6 +38,8 @@ type qemuAmd64 struct {
|
||||
snpIdBlock string
|
||||
|
||||
snpIdAuth string
|
||||
|
||||
snpGuestPolicy *uint64
|
||||
}
|
||||
|
||||
const (
|
||||
@ -126,11 +128,12 @@ func newQemuArch(config HypervisorConfig) (qemuArch, error) {
|
||||
protection: noneProtection,
|
||||
legacySerial: config.LegacySerial,
|
||||
},
|
||||
vmFactory: factory,
|
||||
snpGuest: config.SevSnpGuest,
|
||||
qgsPort: config.QgsPort,
|
||||
snpIdBlock: config.SnpIdBlock,
|
||||
snpIdAuth: config.SnpIdAuth,
|
||||
vmFactory: factory,
|
||||
snpGuest: config.SevSnpGuest,
|
||||
qgsPort: config.QgsPort,
|
||||
snpIdBlock: config.SnpIdBlock,
|
||||
snpIdAuth: config.SnpIdAuth,
|
||||
snpGuestPolicy: config.SnpGuestPolicy,
|
||||
}
|
||||
|
||||
if config.ConfidentialGuest {
|
||||
@ -315,6 +318,7 @@ func (q *qemuAmd64) appendProtectionDevice(devices []govmmQemu.Device, firmware,
|
||||
CBitPos: cpuid.AMDMemEncrypt.CBitPosition,
|
||||
ReducedPhysBits: 1,
|
||||
InitdataDigest: initdataDigest,
|
||||
SnpGuestPolicy: q.snpGuestPolicy,
|
||||
}
|
||||
if q.snpIdBlock != "" && q.snpIdAuth != "" {
|
||||
obj.SnpIdBlock = q.snpIdBlock
|
||||
|
Loading…
Reference in New Issue
Block a user