Skip to content

Commit

Permalink
fix: add upgrade errata for arm64/zboot kernels
Browse files Browse the repository at this point in the history
Fixes #8854

Talos 1.8.0 instroduces EFI ZBoot compression, and kexec from 1.7.0 to
compressed kernel doesn't work.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
  • Loading branch information
smira committed Jun 3, 2024
1 parent 9a23d84 commit 82d9cd3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
44 changes: 36 additions & 8 deletions cmd/installer/pkg/install/errata.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
package install

import (
"bytes"
"compress/gzip"
"context"
"fmt"
"io"
"log"
"os"
"runtime"
"time"

"google.golang.org/grpc"
Expand All @@ -23,17 +27,41 @@ import (
"github.com/siderolabs/talos/pkg/machinery/role"
)

// errataBTF handles the case when kexec from pre-BTF kernel to BTF enabled kernel always fails.
//
// This applies to upgrades of Talos < 1.3.0 to Talos >= 1.3.0.
func errataBTF() {
_, err := os.Stat("/sys/kernel/btf/vmlinux")
if err == nil {
// BTF is enabled, nothing to do
// errataArm64ZBoot handles the case when upgrading from Talos < 1.8.0 on arm64 to compressed kernel.
func errataArm64ZBoot() {
if runtime.GOARCH != "arm64" {
return
}

log.Printf("disabling kexec due to upgrade to the BTF enabled kernel")
oldConfig, err := os.OpenFile("/proc/config.gz", os.O_RDONLY, 0)
if err != nil {
log.Printf("failed to open /proc/config.gz: %s", err)

return
}

defer oldConfig.Close() //nolint:errcheck

r, err := gzip.NewReader(oldConfig)
if err != nil {
log.Printf("failed to read /proc/config.gz: %s", err)

return
}

contents, err := io.ReadAll(r)
if err != nil {
log.Printf("failed to read /proc/config.gz: %s", err)

return
}

if bytes.Contains(contents, []byte("CONFIG_ARM64_ZBOOT=y")) {
// nothing to do
return
}

log.Printf("disabling kexec due to upgrade to the compressed kernel")

if err = pkgkernel.WriteParam(&kernel.Param{
Key: "proc.sys.kernel.kexec_load_disabled",
Expand Down
2 changes: 1 addition & 1 deletion cmd/installer/pkg/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func NewInstaller(ctx context.Context, cmdline *procfs.Cmdline, mode Mode, opts
//
//nolint:gocyclo,cyclop
func (i *Installer) Install(ctx context.Context, mode Mode) (err error) {
errataBTF()
errataArm64ZBoot()

if mode == ModeUpgrade {
if err = i.errataNetIfnames(); err != nil {
Expand Down

0 comments on commit 82d9cd3

Please sign in to comment.