Skip to content

Commit bcc9394

Browse files
author
Manish Ranjan Mahanta
committed
Adding support for ARM64 LCOW
Signed-off-by: Manish Ranjan Mahanta <mmahanta@microsoft.com>
1 parent 6eb7cd9 commit bcc9394

2 files changed

Lines changed: 32 additions & 4 deletions

File tree

cmd/runhcs/create-scratch.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package main
44

55
import (
66
gcontext "context"
7+
"runtime"
78

89
"github.com/Microsoft/hcsshim/internal/appargs"
910
"github.com/Microsoft/hcsshim/internal/lcow"
@@ -72,6 +73,13 @@ var createScratchCommand = cli.Command{
7273
sizeGB = lcow.DefaultScratchSizeGB
7374
}
7475

76+
if runtime.GOARCH == "arm64" {
77+
// Direct-boot is not supported on ARM64, so disable KernelDirect even if the flag is set.
78+
opts.KernelDirect = false
79+
// ARM64 doesn't support VPMem yet, so disable it even if the flag is set.
80+
opts.VPMemDeviceCount = 0
81+
}
82+
7583
convertUVM, err := uvm.CreateLCOW(ctx, opts)
7684
if err != nil {
7785
return errors.Wrapf(err, "failed to create '%s'", opts.ID)

internal/uvm/create_lcow.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"net"
1111
"os"
1212
"path/filepath"
13+
"runtime"
1314
"strings"
1415

1516
"github.com/Microsoft/go-winio"
@@ -181,6 +182,12 @@ func NewDefaultOptionsLCOW(id, owner string) *OptionsLCOW {
181182

182183
opts.UpdateBootFilesPath(context.TODO(), defaultLCOWOSBootFilesPath())
183184

185+
if runtime.GOARCH == "arm64" {
186+
// ARM64 doesn't support KernelDirect, so disable it even if the flag is set.
187+
opts.KernelDirect = false
188+
// ARM64 doesn't support VPMem yet, so disable it even if the flag is set.
189+
opts.VPMemDeviceCount = 0
190+
}
184191
return opts
185192
}
186193

@@ -218,11 +225,12 @@ func (opts *OptionsLCOW) UpdateBootFilesPath(ctx context.Context, path string) {
218225
}).Debug("updated LCOW root filesystem to " + VhdFile)
219226
}
220227

221-
if opts.KernelDirect {
228+
if opts.KernelDirect && runtime.GOARCH != "arm64" {
222229
// KernelDirect supports uncompressed kernel if the kernel is present.
223230
// Default to uncompressed if on box. NOTE: If `kernel` is already
224231
// uncompressed and simply named 'kernel' it will still be used
225232
// uncompressed automatically.
233+
// ARM64 doesn't support KernelDirect, so skip this logic in that case.
226234
if _, err := os.Stat(filepath.Join(opts.BootFilesPath, UncompressedKernelFile)); err == nil {
227235
opts.KernelFile = UncompressedKernelFile
228236

@@ -807,14 +815,20 @@ func makeLCOWDoc(ctx context.Context, opts *OptionsLCOW, uvm *UtilityVM) (_ *hcs
807815
vmDebugging := false
808816
if opts.ConsolePipe != "" {
809817
vmDebugging = true
810-
kernelArgs += " 8250_core.nr_uarts=1 8250_core.skip_txen_test=1 console=ttyS0,115200"
818+
if runtime.GOARCH == "arm64" {
819+
kernelArgs += " console=ttyAMA0,115200"
820+
} else {
821+
kernelArgs += " 8250_core.nr_uarts=1 8250_core.skip_txen_test=1 console=ttyS0,115200"
822+
}
811823
doc.VirtualMachine.Devices.ComPorts = map[string]hcsschema.ComPort{
812824
"0": { // Which is actually COM1
813825
NamedPipe: opts.ConsolePipe,
814826
},
815827
}
816828
} else {
817-
kernelArgs += " 8250_core.nr_uarts=0"
829+
if runtime.GOARCH != "arm64" {
830+
kernelArgs += " 8250_core.nr_uarts=0"
831+
}
818832
}
819833

820834
if opts.EnableGraphicsConsole {
@@ -835,7 +849,7 @@ func makeLCOWDoc(ctx context.Context, opts *OptionsLCOW, uvm *UtilityVM) (_ *hcs
835849
kernelArgs += " " + opts.KernelBootOptions
836850
}
837851

838-
if !opts.VPCIEnabled {
852+
if runtime.GOARCH != "arm64" && !opts.VPCIEnabled {
839853
kernelArgs += ` pci=off`
840854
}
841855

@@ -967,6 +981,12 @@ func CreateLCOW(ctx context.Context, opts *OptionsLCOW) (_ *UtilityVM, err error
967981
return nil, errors.Wrap(err, errBadUVMOpts.Error())
968982
}
969983

984+
// KernelDirect and VPMem devices are not supported by Hyper-V on ARM64.
985+
if runtime.GOARCH == "arm64" {
986+
opts.KernelDirect = false
987+
opts.VPMemDeviceCount = 0
988+
}
989+
970990
// HCS config for SNP isolated vm is quite different to the usual case
971991
var doc *hcsschema.ComputeSystem
972992
if opts.SecurityPolicyEnabled {

0 commit comments

Comments
 (0)