Andrey Smirnov 4a052eadf3
fix: disable kexec on upgrades from pre-BTF kernel
Enabling BTF in the kernel brakes kexec from pre-BTF kernel (e.g. when
upgrading from 1.2.x to 1.3.x).

As there's no way to detect Talos version in the installer at the
moment, use another way to detect whether BTF is enabled in the Talos
version which is running right now.

Fixes #6443

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2022-11-24 22:48:39 +04:00

34 lines
897 B
Go

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package install
import (
"log"
"os"
pkgkernel "github.com/siderolabs/talos/pkg/kernel"
"github.com/siderolabs/talos/pkg/machinery/kernel"
)
// 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
return
}
log.Printf("disabling kexec due to upgrade to the BTF enabled kernel")
if err = pkgkernel.WriteParam(&kernel.Param{
Key: "proc.sys.kernel.kexec_load_disabled",
Value: "1",
}); err != nil {
log.Printf("failed to disable kexec: %s", err)
}
}