diff --git a/internal/builder/vm/lcow/boot.go b/internal/builder/vm/lcow/boot.go index d7f052d93a..84ca89c957 100644 --- a/internal/builder/vm/lcow/boot.go +++ b/internal/builder/vm/lcow/boot.go @@ -7,6 +7,7 @@ import ( "fmt" "os" "path/filepath" + "runtime" runhcsoptions "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" @@ -87,6 +88,11 @@ func parseBootOptions(ctx context.Context, opts *runhcsoptions.Options, annotati // uncompressed and simply named 'kernel' it will still be used // uncompressed automatically. kernelDirectBootSupported := osversion.Build() >= 18286 + if runtime.GOARCH == "arm64" { + // KernelDirectBoot is currently not supported by Hyper-V on arm64. + // Todo: enable this by default once KernelDirectBoot on arm64 is supported. + kernelDirectBootSupported = false + } useKernelDirect := oci.ParseAnnotationsBool(ctx, annotations, shimannotations.KernelDirectBoot, kernelDirectBootSupported) log.G(ctx).WithFields(logrus.Fields{ diff --git a/internal/builder/vm/lcow/devices.go b/internal/builder/vm/lcow/devices.go index ef668c7371..3dbcf5d7ec 100644 --- a/internal/builder/vm/lcow/devices.go +++ b/internal/builder/vm/lcow/devices.go @@ -6,6 +6,7 @@ import ( "context" "fmt" "path/filepath" + "runtime" "strings" "github.com/Microsoft/hcsshim/internal/controller/device/vpci" @@ -45,8 +46,9 @@ func parseDeviceOptions( vpmemCount := oci.ParseAnnotationsUint32(ctx, annotations, shimannotations.VPMemCount, vmutils.DefaultVPMEMCount) vpmemSize := oci.ParseAnnotationsUint64(ctx, annotations, shimannotations.VPMemSize, vmutils.DefaultVPMemSizeBytes) - // VPMem is not supported by the enlightened kernel for SNP (confidential VMs). - if isFullyPhysicallyBacked || isConfidential { + // VPMem is not supported by the enlightened kernel for SNP (confidential VMs, and Hyper-V on arm64). + // Todo: Remove arm64 check once VPMem is supported by Hyper-V on arm64. + if isFullyPhysicallyBacked || isConfidential || runtime.GOARCH == "arm64" { vpmemCount = 0 } diff --git a/internal/uvm/create.go b/internal/uvm/create.go index 846982747b..65ce81901b 100644 --- a/internal/uvm/create.go +++ b/internal/uvm/create.go @@ -8,6 +8,7 @@ import ( "fmt" "os" "path/filepath" + "runtime" "github.com/Microsoft/go-winio/pkg/guid" "github.com/sirupsen/logrus" @@ -189,6 +190,12 @@ func VerifyOptions(_ context.Context, options interface{}) error { return errors.New("resource partition ID and CPU group ID cannot be set at the same time") } } + if runtime.GOARCH == "arm64" { + // ARM64 specific checks for currently unsupported features. These can be removed when the features are supported on ARM64. + if opts.VPMemDeviceCount > 0 { + return errors.New("VPMem devices are not supported on ARM64") + } + } case *OptionsWCOW: if opts.EnableDeferredCommit && !opts.AllowOvercommit { return errors.New("EnableDeferredCommit is not supported on physically backed VMs") diff --git a/internal/uvm/create_lcow.go b/internal/uvm/create_lcow.go index 521e272543..9ac7018665 100644 --- a/internal/uvm/create_lcow.go +++ b/internal/uvm/create_lcow.go @@ -10,6 +10,7 @@ import ( "net" "os" "path/filepath" + "runtime" "strings" "github.com/Microsoft/go-winio" @@ -113,6 +114,14 @@ type OptionsLCOW struct { func NewDefaultOptionsLCOW(id, owner string) *OptionsLCOW { // Use KernelDirect boot by default on all builds that support it. kernelDirectSupported := osversion.Build() >= 18286 + var vPmemCount uint32 = vmutils.DefaultVPMEMCount + if runtime.GOARCH == "arm64" { + // Todo: Add a conditional check for osversion once KernelDirect + // becomes available on ARM64, and enable it for supported versions. + // This is used by create-scratch and cannot be overriden by annotations + kernelDirectSupported = false + vPmemCount = 0 + } opts := &OptionsLCOW{ Options: newDefaultOptions(id, owner), KernelFile: vmutils.KernelFile, @@ -124,7 +133,7 @@ func NewDefaultOptionsLCOW(id, owner string) *OptionsLCOW { ForwardStdout: false, ForwardStderr: true, OutputHandlerCreator: vmutils.ParseGCSLogrus, - VPMemDeviceCount: vmutils.DefaultVPMEMCount, + VPMemDeviceCount: vPmemCount, VPMemSizeBytes: vmutils.DefaultVPMemSizeBytes, VPMemNoMultiMapping: osversion.Get().Build < osversion.V19H1, PreferredRootFSType: PreferredRootFSTypeInitRd, @@ -775,14 +784,20 @@ func MakeLCOWDoc(ctx context.Context, opts *OptionsLCOW, uvm *UtilityVM) (_ *hcs vmDebugging := false if opts.ConsolePipe != "" { vmDebugging = true - kernelArgs += " 8250_core.nr_uarts=1 8250_core.skip_txen_test=1 console=ttyS0,115200" + if runtime.GOARCH == "arm64" { + kernelArgs += " console=ttyAMA0,115200" + } else { + kernelArgs += " 8250_core.nr_uarts=1 8250_core.skip_txen_test=1 console=ttyS0,115200" + } doc.VirtualMachine.Devices.ComPorts = map[string]hcsschema.ComPort{ "0": { // Which is actually COM1 NamedPipe: opts.ConsolePipe, }, } } else { - kernelArgs += " 8250_core.nr_uarts=0" + if runtime.GOARCH != "arm64" { + kernelArgs += " 8250_core.nr_uarts=0" + } } if opts.EnableGraphicsConsole {