clh: Use HVC console with TDX

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 <fabiano.fidencio@intel.com>
This commit is contained in:
Fabiano Fidêncio 2022-08-24 17:04:59 +02:00
parent c0cb3cd4d8
commit d4b67613f0

View File

@ -265,6 +265,13 @@ var clhKernelParams = []Param{
var clhDebugKernelParams = []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 {"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 // Followed by extra debug parameters if debug enabled in configuration file
if clh.config.Debug { if clh.config.Debug {
if clh.config.ConfidentialGuest {
params = append(params, clhDebugConfidentialGuestKernelParams...)
} else {
params = append(params, clhDebugKernelParams...) params = append(params, clhDebugKernelParams...)
}
params = append(params, clhDebugKernelParamsCommon...)
} else { } else {
// start the guest kernel with 'quiet' in non-debug mode // start the guest kernel with 'quiet' in non-debug mode
params = append(params, Param{"quiet", ""}) params = append(params, Param{"quiet", ""})
@ -550,6 +562,17 @@ func (clh *cloudHypervisor) CreateVM(ctx context.Context, id string, network Net
clh.vmconfig.Payload.SetInitramfs(initrdPath) clh.vmconfig.Payload.SetInitramfs(initrdPath)
} }
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.Serial = chclient.NewConsoleConfig(cctOFF)
} else {
// Use serial port as the guest console only in debug mode, // Use serial port as the guest console only in debug mode,
// so that we can gather early OS booting log // so that we can gather early OS booting log
if clh.config.Debug { if clh.config.Debug {
@ -559,6 +582,7 @@ func (clh *cloudHypervisor) CreateVM(ctx context.Context, id string, network Net
} }
clh.vmconfig.Console = chclient.NewConsoleConfig(cctOFF) clh.vmconfig.Console = chclient.NewConsoleConfig(cctOFF)
}
cpu_topology := chclient.NewCpuTopology() cpu_topology := chclient.NewCpuTopology()
cpu_topology.ThreadsPerCore = func(i int32) *int32 { return &i }(1) cpu_topology.ThreadsPerCore = func(i int32) *int32 { return &i }(1)