mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-25 15:02:45 +00:00
virtcontainers: Move guest protection definitions to hypervisor.go
They're not QEMU specific, other VMMs may implement support for it. Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
This commit is contained in:
parent
b28d0274ff
commit
10ae05914c
@ -908,6 +908,57 @@ func generateVMSocket(id string, vmStogarePath string) (interface{}, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Kind of guest protection
|
||||||
|
type guestProtection uint8
|
||||||
|
|
||||||
|
const (
|
||||||
|
noneProtection guestProtection = iota
|
||||||
|
|
||||||
|
//Intel Trust Domain Extensions
|
||||||
|
//https://software.intel.com/content/www/us/en/develop/articles/intel-trust-domain-extensions.html
|
||||||
|
// Exclude from lint checking for it won't be used on arm64 code
|
||||||
|
tdxProtection
|
||||||
|
|
||||||
|
// AMD Secure Encrypted Virtualization
|
||||||
|
// https://developer.amd.com/sev/
|
||||||
|
// Exclude from lint checking for it won't be used on arm64 code
|
||||||
|
sevProtection
|
||||||
|
|
||||||
|
// IBM POWER 9 Protected Execution Facility
|
||||||
|
// https://www.kernel.org/doc/html/latest/powerpc/ultravisor.html
|
||||||
|
// Exclude from lint checking for it won't be used on arm64 code
|
||||||
|
pefProtection
|
||||||
|
|
||||||
|
// IBM Secure Execution (IBM Z & LinuxONE)
|
||||||
|
// https://www.kernel.org/doc/html/latest/virt/kvm/s390-pv.html
|
||||||
|
// Exclude from lint checking for it won't be used on arm64 code
|
||||||
|
seProtection
|
||||||
|
)
|
||||||
|
|
||||||
|
var guestProtectionStr = [...]string{
|
||||||
|
noneProtection: "none",
|
||||||
|
pefProtection: "pef",
|
||||||
|
seProtection: "se",
|
||||||
|
sevProtection: "sev",
|
||||||
|
tdxProtection: "tdx",
|
||||||
|
}
|
||||||
|
|
||||||
|
func (gp guestProtection) String() string {
|
||||||
|
return guestProtectionStr[gp]
|
||||||
|
}
|
||||||
|
|
||||||
|
func genericAvailableGuestProtections() (protections []string) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func AvailableGuestProtections() (protections []string) {
|
||||||
|
gp, err := availableGuestProtection()
|
||||||
|
if err != nil || gp == noneProtection {
|
||||||
|
return genericAvailableGuestProtections()
|
||||||
|
}
|
||||||
|
return []string{gp.String()}
|
||||||
|
}
|
||||||
|
|
||||||
// hypervisor is the virtcontainers hypervisor interface.
|
// hypervisor is the virtcontainers hypervisor interface.
|
||||||
// The default hypervisor implementation is Qemu.
|
// The default hypervisor implementation is Qemu.
|
||||||
type Hypervisor interface {
|
type Hypervisor interface {
|
||||||
|
@ -7,6 +7,14 @@ package virtcontainers
|
|||||||
|
|
||||||
import "os"
|
import "os"
|
||||||
|
|
||||||
|
const (
|
||||||
|
tdxSysFirmwareDir = "/sys/firmware/tdx_seam/"
|
||||||
|
|
||||||
|
tdxCPUFlag = "tdx"
|
||||||
|
|
||||||
|
sevKvmParameterPath = "/sys/module/kvm_amd/parameters/sev"
|
||||||
|
)
|
||||||
|
|
||||||
// Implementation of this function is architecture specific
|
// Implementation of this function is architecture specific
|
||||||
func availableGuestProtection() (guestProtection, error) {
|
func availableGuestProtection() (guestProtection, error) {
|
||||||
flags, err := CPUFlags(procCPUInfo)
|
flags, err := CPUFlags(procCPUInfo)
|
||||||
|
@ -36,12 +36,6 @@ const (
|
|||||||
defaultQemuMachineOptions = "accel=kvm,kernel_irqchip=on"
|
defaultQemuMachineOptions = "accel=kvm,kernel_irqchip=on"
|
||||||
|
|
||||||
qmpMigrationWaitTimeout = 5 * time.Second
|
qmpMigrationWaitTimeout = 5 * time.Second
|
||||||
|
|
||||||
tdxSysFirmwareDir = "/sys/firmware/tdx_seam/"
|
|
||||||
|
|
||||||
tdxCPUFlag = "tdx"
|
|
||||||
|
|
||||||
sevKvmParameterPath = "/sys/module/kvm_amd/parameters/sev"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var qemuPaths = map[string]string{
|
var qemuPaths = map[string]string{
|
||||||
|
@ -150,57 +150,6 @@ type qemuArch interface {
|
|||||||
appendProtectionDevice(devices []govmmQemu.Device, firmware, firmwareVolume string) ([]govmmQemu.Device, string, error)
|
appendProtectionDevice(devices []govmmQemu.Device, firmware, firmwareVolume string) ([]govmmQemu.Device, string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kind of guest protection
|
|
||||||
type guestProtection uint8
|
|
||||||
|
|
||||||
const (
|
|
||||||
noneProtection guestProtection = iota
|
|
||||||
|
|
||||||
//Intel Trust Domain Extensions
|
|
||||||
//https://software.intel.com/content/www/us/en/develop/articles/intel-trust-domain-extensions.html
|
|
||||||
// Exclude from lint checking for it won't be used on arm64 code
|
|
||||||
tdxProtection
|
|
||||||
|
|
||||||
// AMD Secure Encrypted Virtualization
|
|
||||||
// https://developer.amd.com/sev/
|
|
||||||
// Exclude from lint checking for it won't be used on arm64 code
|
|
||||||
sevProtection
|
|
||||||
|
|
||||||
// IBM POWER 9 Protected Execution Facility
|
|
||||||
// https://www.kernel.org/doc/html/latest/powerpc/ultravisor.html
|
|
||||||
// Exclude from lint checking for it won't be used on arm64 code
|
|
||||||
pefProtection
|
|
||||||
|
|
||||||
// IBM Secure Execution (IBM Z & LinuxONE)
|
|
||||||
// https://www.kernel.org/doc/html/latest/virt/kvm/s390-pv.html
|
|
||||||
// Exclude from lint checking for it won't be used on arm64 code
|
|
||||||
seProtection
|
|
||||||
)
|
|
||||||
|
|
||||||
var guestProtectionStr = [...]string{
|
|
||||||
noneProtection: "none",
|
|
||||||
pefProtection: "pef",
|
|
||||||
seProtection: "se",
|
|
||||||
sevProtection: "sev",
|
|
||||||
tdxProtection: "tdx",
|
|
||||||
}
|
|
||||||
|
|
||||||
func (gp guestProtection) String() string {
|
|
||||||
return guestProtectionStr[gp]
|
|
||||||
}
|
|
||||||
|
|
||||||
func genericAvailableGuestProtections() (protections []string) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func AvailableGuestProtections() (protections []string) {
|
|
||||||
gp, err := availableGuestProtection()
|
|
||||||
if err != nil || gp == noneProtection {
|
|
||||||
return genericAvailableGuestProtections()
|
|
||||||
}
|
|
||||||
return []string{gp.String()}
|
|
||||||
}
|
|
||||||
|
|
||||||
type qemuArchBase struct {
|
type qemuArchBase struct {
|
||||||
qemuExePath string
|
qemuExePath string
|
||||||
qemuMachine govmmQemu.Machine
|
qemuMachine govmmQemu.Machine
|
||||||
|
Loading…
Reference in New Issue
Block a user