From f454bcdef14fc8ff4bf9d58ea21916bdf3e74eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Wed, 24 Aug 2022 17:04:59 +0200 Subject: [PATCH] clh: Use HVC console with TDX MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As right now the TDX guest kernel doesn't support "serial" console, let's switch to using HVC in this case. Fixes: #4980 Signed-off-by: Fabiano FidĂȘncio --- src/runtime/virtcontainers/clh.go | 44 ++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/src/runtime/virtcontainers/clh.go b/src/runtime/virtcontainers/clh.go index b867d1b821..21b67fa564 100644 --- a/src/runtime/virtcontainers/clh.go +++ b/src/runtime/virtcontainers/clh.go @@ -264,7 +264,14 @@ var clhKernelParams = []Param{ } var clhDebugKernelParams = []Param{ - {"console", "ttyS0,115200n8"}, // enable serial console + {"console", "ttyS0,115200n8"}, // enable serial console +} + +var clhDebugConfidentialGuestKernelParams = []Param{ + {"console", "hvc0"}, // enable HVC console +} + +var clhDebugKernelParamsCommon = []Param{ {"systemd.log_target", "console"}, // send loggng to the console } @@ -496,7 +503,12 @@ func (clh *cloudHypervisor) CreateVM(ctx context.Context, id string, network Net // Followed by extra debug parameters if debug enabled in configuration file if clh.config.Debug { - params = append(params, clhDebugKernelParams...) + if clh.config.ConfidentialGuest { + params = append(params, clhDebugConfidentialGuestKernelParams...) + } else { + params = append(params, clhDebugKernelParams...) + } + params = append(params, clhDebugKernelParamsCommon...) } else { // start the guest kernel with 'quiet' in non-debug mode params = append(params, Param{"quiet", ""}) @@ -550,15 +562,27 @@ func (clh *cloudHypervisor) CreateVM(ctx context.Context, id string, network Net clh.vmconfig.Payload.SetInitramfs(initrdPath) } - // Use serial port as the guest console only in debug mode, - // so that we can gather early OS booting log - if clh.config.Debug { - clh.vmconfig.Serial = chclient.NewConsoleConfig(cctTTY) - } else { - clh.vmconfig.Serial = chclient.NewConsoleConfig(cctOFF) - } + if clh.config.ConfidentialGuest { + // Use HVC as the guest console only in debug mode, only + // for Confidential Guests + if clh.config.Debug { + clh.vmconfig.Console = chclient.NewConsoleConfig(cctTTY) + } else { + clh.vmconfig.Console = chclient.NewConsoleConfig(cctOFF) + } - clh.vmconfig.Console = chclient.NewConsoleConfig(cctOFF) + clh.vmconfig.Serial = chclient.NewConsoleConfig(cctOFF) + } else { + // Use serial port as the guest console only in debug mode, + // so that we can gather early OS booting log + if clh.config.Debug { + clh.vmconfig.Serial = chclient.NewConsoleConfig(cctTTY) + } else { + clh.vmconfig.Serial = chclient.NewConsoleConfig(cctOFF) + } + + clh.vmconfig.Console = chclient.NewConsoleConfig(cctOFF) + } cpu_topology := chclient.NewCpuTopology() cpu_topology.ThreadsPerCore = func(i int32) *int32 { return &i }(1)