mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-22 11:13:22 +00:00
Merge pull request #9806 from niteeshkd/nd_snp_certs
runtime: pass certificates to get extended attestation report for SNP coco
This commit is contained in:
commit
78bbc51ff0
18
.github/workflows/run-kata-coco-tests.yaml
vendored
18
.github/workflows/run-kata-coco-tests.yaml
vendored
@ -174,6 +174,8 @@ jobs:
|
|||||||
KUBECONFIG: /home/kata/.kube/config
|
KUBECONFIG: /home/kata/.kube/config
|
||||||
KUBERNETES: "vanilla"
|
KUBERNETES: "vanilla"
|
||||||
USING_NFD: "false"
|
USING_NFD: "false"
|
||||||
|
KBS: "true"
|
||||||
|
KBS_INGRESS: "nodeport"
|
||||||
K8S_TEST_HOST_TYPE: "baremetal"
|
K8S_TEST_HOST_TYPE: "baremetal"
|
||||||
SNAPSHOTTER: ${{ matrix.snapshotter }}
|
SNAPSHOTTER: ${{ matrix.snapshotter }}
|
||||||
PULL_TYPE: ${{ matrix.pull-type }}
|
PULL_TYPE: ${{ matrix.pull-type }}
|
||||||
@ -199,6 +201,18 @@ jobs:
|
|||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
run: bash tests/integration/kubernetes/gha-run.sh deploy-kata-snp
|
run: bash tests/integration/kubernetes/gha-run.sh deploy-kata-snp
|
||||||
|
|
||||||
|
- name: Uninstall previous `kbs-client`
|
||||||
|
timeout-minutes: 10
|
||||||
|
run: bash tests/integration/kubernetes/gha-run.sh uninstall-kbs-client
|
||||||
|
|
||||||
|
- name: Deploy CoCo KBS
|
||||||
|
timeout-minutes: 10
|
||||||
|
run: bash tests/integration/kubernetes/gha-run.sh deploy-coco-kbs
|
||||||
|
|
||||||
|
- name: Install `kbs-client`
|
||||||
|
timeout-minutes: 10
|
||||||
|
run: bash tests/integration/kubernetes/gha-run.sh install-kbs-client
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
run: bash tests/integration/kubernetes/gha-run.sh run-tests
|
run: bash tests/integration/kubernetes/gha-run.sh run-tests
|
||||||
@ -211,6 +225,10 @@ jobs:
|
|||||||
if: always()
|
if: always()
|
||||||
run: bash tests/integration/kubernetes/gha-run.sh cleanup-snapshotter
|
run: bash tests/integration/kubernetes/gha-run.sh cleanup-snapshotter
|
||||||
|
|
||||||
|
- name: Delete CoCo KBS
|
||||||
|
if: always()
|
||||||
|
run: bash tests/integration/kubernetes/gha-run.sh delete-coco-kbs
|
||||||
|
|
||||||
# Generate jobs for testing CoCo on non-TEE environments
|
# Generate jobs for testing CoCo on non-TEE environments
|
||||||
run-k8s-tests-coco-nontee:
|
run-k8s-tests-coco-nontee:
|
||||||
strategy:
|
strategy:
|
||||||
|
@ -150,6 +150,7 @@ FIRMWARETDVFVOLUMEPATH :=
|
|||||||
|
|
||||||
FIRMWARESEVPATH := $(PREFIXDEPS)/share/ovmf/OVMF.fd
|
FIRMWARESEVPATH := $(PREFIXDEPS)/share/ovmf/OVMF.fd
|
||||||
FIRMWARESNPPATH := $(PREFIXDEPS)/share/ovmf/AMDSEV.fd
|
FIRMWARESNPPATH := $(PREFIXDEPS)/share/ovmf/AMDSEV.fd
|
||||||
|
SNPCERTSPATH := /opt/snp/cert_chain.cert
|
||||||
|
|
||||||
ROOTMEASURECONFIG ?= ""
|
ROOTMEASURECONFIG ?= ""
|
||||||
KERNELPARAMS += $(ROOTMEASURECONFIG)
|
KERNELPARAMS += $(ROOTMEASURECONFIG)
|
||||||
@ -679,6 +680,7 @@ USER_VARS += FIRMWARETDVFPATH
|
|||||||
USER_VARS += FIRMWAREVOLUMEPATH
|
USER_VARS += FIRMWAREVOLUMEPATH
|
||||||
USER_VARS += FIRMWARETDVFVOLUMEPATH
|
USER_VARS += FIRMWARETDVFVOLUMEPATH
|
||||||
USER_VARS += FIRMWARESNPPATH
|
USER_VARS += FIRMWARESNPPATH
|
||||||
|
USER_VARS += SNPCERTSPATH
|
||||||
USER_VARS += MACHINEACCELERATORS
|
USER_VARS += MACHINEACCELERATORS
|
||||||
USER_VARS += CPUFEATURES
|
USER_VARS += CPUFEATURES
|
||||||
USER_VARS += TDXCPUFEATURES
|
USER_VARS += TDXCPUFEATURES
|
||||||
|
@ -44,6 +44,11 @@ confidential_guest = true
|
|||||||
# enable SEV SNP VMs
|
# enable SEV SNP VMs
|
||||||
sev_snp_guest = true
|
sev_snp_guest = true
|
||||||
|
|
||||||
|
# The path to the file containing the SNP certificate chain (including
|
||||||
|
# VCEK/VLEK certificates). This wil be used to get the extended attestation
|
||||||
|
# report from the guest. The default path is @SNPCERTSPATH@.
|
||||||
|
snp_certs_path = "@SNPCERTSPATH@"
|
||||||
|
|
||||||
# Enable running QEMU VMM as a non-root user.
|
# Enable running QEMU VMM as a non-root user.
|
||||||
# By default QEMU VMM run as root. When this is set to true, QEMU VMM process runs as
|
# By default QEMU VMM run as root. When this is set to true, QEMU VMM process runs as
|
||||||
# a non-root random user. See documentation for the limitations of this mode.
|
# a non-root random user. See documentation for the limitations of this mode.
|
||||||
|
@ -300,6 +300,10 @@ type Object struct {
|
|||||||
// and UEFI program image.
|
// and UEFI program image.
|
||||||
FirmwareVolume string
|
FirmwareVolume string
|
||||||
|
|
||||||
|
// The path to the file containing the AMD SEV-SNP certificate chain
|
||||||
|
// (including VCEK/VLEK certificates).
|
||||||
|
SnpCertsPath string
|
||||||
|
|
||||||
// CBitPos is the location of the C-bit in a guest page table entry
|
// CBitPos is the location of the C-bit in a guest page table entry
|
||||||
// This is only relevant for sev-guest objects
|
// This is only relevant for sev-guest objects
|
||||||
CBitPos uint32
|
CBitPos uint32
|
||||||
@ -388,6 +392,9 @@ func (object Object) QemuParams(config *Config) []string {
|
|||||||
objectParams = append(objectParams, fmt.Sprintf("cbitpos=%d", object.CBitPos))
|
objectParams = append(objectParams, fmt.Sprintf("cbitpos=%d", object.CBitPos))
|
||||||
objectParams = append(objectParams, fmt.Sprintf("reduced-phys-bits=%d", object.ReducedPhysBits))
|
objectParams = append(objectParams, fmt.Sprintf("reduced-phys-bits=%d", object.ReducedPhysBits))
|
||||||
objectParams = append(objectParams, "kernel-hashes=on")
|
objectParams = append(objectParams, "kernel-hashes=on")
|
||||||
|
if object.SnpCertsPath != "" {
|
||||||
|
objectParams = append(objectParams, fmt.Sprintf("certs-path=%s", object.SnpCertsPath))
|
||||||
|
}
|
||||||
|
|
||||||
driveParams = append(driveParams, "if=pflash,format=raw,readonly=on")
|
driveParams = append(driveParams, "if=pflash,format=raw,readonly=on")
|
||||||
driveParams = append(driveParams, fmt.Sprintf("file=%s", object.File))
|
driveParams = append(driveParams, fmt.Sprintf("file=%s", object.File))
|
||||||
|
@ -117,3 +117,5 @@ const defaultPCIeSwitchPort = 0
|
|||||||
|
|
||||||
const defaultRemoteHypervisorSocket = "/run/peerpod/hypervisor.sock"
|
const defaultRemoteHypervisorSocket = "/run/peerpod/hypervisor.sock"
|
||||||
const defaultRemoteHypervisorTimeout = 600
|
const defaultRemoteHypervisorTimeout = 600
|
||||||
|
|
||||||
|
const defaultSnpCertsPath = "/opt/snp/cert_chain.cert"
|
||||||
|
@ -106,6 +106,7 @@ type hypervisor struct {
|
|||||||
SeccompSandbox string `toml:"seccompsandbox"`
|
SeccompSandbox string `toml:"seccompsandbox"`
|
||||||
BlockDeviceAIO string `toml:"block_device_aio"`
|
BlockDeviceAIO string `toml:"block_device_aio"`
|
||||||
RemoteHypervisorSocket string `toml:"remote_hypervisor_socket"`
|
RemoteHypervisorSocket string `toml:"remote_hypervisor_socket"`
|
||||||
|
SnpCertsPath string `toml:"snp_certs_path"`
|
||||||
HypervisorPathList []string `toml:"valid_hypervisor_paths"`
|
HypervisorPathList []string `toml:"valid_hypervisor_paths"`
|
||||||
JailerPathList []string `toml:"valid_jailer_paths"`
|
JailerPathList []string `toml:"valid_jailer_paths"`
|
||||||
CtlPathList []string `toml:"valid_ctlpaths"`
|
CtlPathList []string `toml:"valid_ctlpaths"`
|
||||||
@ -295,6 +296,24 @@ func (h hypervisor) firmware() (string, error) {
|
|||||||
return ResolvePath(p)
|
return ResolvePath(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h hypervisor) snpCertsPath() (string, error) {
|
||||||
|
p := h.SnpCertsPath
|
||||||
|
|
||||||
|
if p == "" {
|
||||||
|
p = defaultSnpCertsPath
|
||||||
|
}
|
||||||
|
|
||||||
|
path, err := ResolvePath(p)
|
||||||
|
if err != nil {
|
||||||
|
if p == defaultSnpCertsPath {
|
||||||
|
msg := fmt.Sprintf("failed to resolve SNP certificates path: %s", defaultSnpCertsPath)
|
||||||
|
kataUtilsLogger.Warn(msg)
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return path, err
|
||||||
|
}
|
||||||
|
|
||||||
func (h hypervisor) coldPlugVFIO() config.PCIePort {
|
func (h hypervisor) coldPlugVFIO() config.PCIePort {
|
||||||
if h.ColdPlugVFIO == "" {
|
if h.ColdPlugVFIO == "" {
|
||||||
return defaultColdPlugVFIO
|
return defaultColdPlugVFIO
|
||||||
@ -850,6 +869,11 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
|
|||||||
return vc.HypervisorConfig{}, err
|
return vc.HypervisorConfig{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snpCertsPath, err := h.snpCertsPath()
|
||||||
|
if err != nil {
|
||||||
|
return vc.HypervisorConfig{}, err
|
||||||
|
}
|
||||||
|
|
||||||
machineAccelerators := h.machineAccelerators()
|
machineAccelerators := h.machineAccelerators()
|
||||||
cpuFeatures := h.cpuFeatures()
|
cpuFeatures := h.cpuFeatures()
|
||||||
kernelParams := h.kernelParams()
|
kernelParams := h.kernelParams()
|
||||||
@ -914,6 +938,7 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
|
|||||||
RootfsType: rootfsType,
|
RootfsType: rootfsType,
|
||||||
FirmwarePath: firmware,
|
FirmwarePath: firmware,
|
||||||
FirmwareVolumePath: firmwareVolume,
|
FirmwareVolumePath: firmwareVolume,
|
||||||
|
SnpCertsPath: snpCertsPath,
|
||||||
PFlash: pflashes,
|
PFlash: pflashes,
|
||||||
MachineAccelerators: machineAccelerators,
|
MachineAccelerators: machineAccelerators,
|
||||||
CPUFeatures: cpuFeatures,
|
CPUFeatures: cpuFeatures,
|
||||||
|
@ -475,6 +475,10 @@ type HypervisorConfig struct {
|
|||||||
// The user maps to the uid.
|
// The user maps to the uid.
|
||||||
User string
|
User string
|
||||||
|
|
||||||
|
// The path to the file containing the AMD SEV-SNP certificate chain
|
||||||
|
// (including VCEK/VLEK certificates).
|
||||||
|
SnpCertsPath string
|
||||||
|
|
||||||
// KernelParams are additional guest kernel parameters.
|
// KernelParams are additional guest kernel parameters.
|
||||||
KernelParams []Param
|
KernelParams []Param
|
||||||
|
|
||||||
|
@ -33,6 +33,8 @@ type qemuAmd64 struct {
|
|||||||
sgxEPCSize int64
|
sgxEPCSize int64
|
||||||
|
|
||||||
qgsPort uint32
|
qgsPort uint32
|
||||||
|
|
||||||
|
snpCertsPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -128,6 +130,7 @@ func newQemuArch(config HypervisorConfig) (qemuArch, error) {
|
|||||||
vmFactory: factory,
|
vmFactory: factory,
|
||||||
snpGuest: config.SevSnpGuest,
|
snpGuest: config.SevSnpGuest,
|
||||||
qgsPort: config.QgsPort,
|
qgsPort: config.QgsPort,
|
||||||
|
snpCertsPath: config.SnpCertsPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.ConfidentialGuest {
|
if config.ConfidentialGuest {
|
||||||
@ -311,6 +314,7 @@ func (q *qemuAmd64) appendProtectionDevice(devices []govmmQemu.Device, firmware,
|
|||||||
File: firmware,
|
File: firmware,
|
||||||
CBitPos: cpuid.AMDMemEncrypt.CBitPosition,
|
CBitPos: cpuid.AMDMemEncrypt.CBitPosition,
|
||||||
ReducedPhysBits: 1,
|
ReducedPhysBits: 1,
|
||||||
|
SnpCertsPath: q.snpCertsPath,
|
||||||
}), "", nil
|
}), "", nil
|
||||||
case noneProtection:
|
case noneProtection:
|
||||||
|
|
||||||
|
@ -20,6 +20,9 @@ setup() {
|
|||||||
if [ "${KBS}" = "false" ]; then
|
if [ "${KBS}" = "false" ]; then
|
||||||
skip "Test skipped as KBS not setup"
|
skip "Test skipped as KBS not setup"
|
||||||
fi
|
fi
|
||||||
|
if [ "${KATA_HYPERVISOR}" = "qemu-snp" ]; then
|
||||||
|
skip "Test skipped as SNP attestation not setup"
|
||||||
|
fi
|
||||||
|
|
||||||
setup_common
|
setup_common
|
||||||
get_pod_config_dir
|
get_pod_config_dir
|
||||||
@ -90,6 +93,9 @@ teardown() {
|
|||||||
if [ "${KBS}" = "false" ]; then
|
if [ "${KBS}" = "false" ]; then
|
||||||
skip "Test skipped as KBS not setup"
|
skip "Test skipped as KBS not setup"
|
||||||
fi
|
fi
|
||||||
|
if [ "${KATA_HYPERVISOR}" = "qemu-snp" ]; then
|
||||||
|
skip "Test skipped as SNP attestation not setup"
|
||||||
|
fi
|
||||||
|
|
||||||
[ -n "${pod_name:-}" ] && kubectl describe "pod/${pod_name}" || true
|
[ -n "${pod_name:-}" ] && kubectl describe "pod/${pod_name}" || true
|
||||||
[ -n "${pod_config_dir:-}" ] && kubectl delete -f "${K8S_TEST_YAML}" || true
|
[ -n "${pod_config_dir:-}" ] && kubectl delete -f "${K8S_TEST_YAML}" || true
|
||||||
|
Loading…
Reference in New Issue
Block a user