mirror of
				https://github.com/siderolabs/talos.git
				synced 2025-11-04 10:21:13 +01:00 
			
		
		
		
	fix: add upgrade errata for arm64/zboot kernels
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>
This commit is contained in:
		
							parent
							
								
									9a23d846c1
								
							
						
					
					
						commit
						82d9cd3229
					
				@ -5,10 +5,14 @@
 | 
				
			|||||||
package install
 | 
					package install
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"bytes"
 | 
				
			||||||
 | 
						"compress/gzip"
 | 
				
			||||||
	"context"
 | 
						"context"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
 | 
						"io"
 | 
				
			||||||
	"log"
 | 
						"log"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
 | 
						"runtime"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"google.golang.org/grpc"
 | 
						"google.golang.org/grpc"
 | 
				
			||||||
@ -23,17 +27,41 @@ import (
 | 
				
			|||||||
	"github.com/siderolabs/talos/pkg/machinery/role"
 | 
						"github.com/siderolabs/talos/pkg/machinery/role"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// errataBTF handles the case when kexec from pre-BTF kernel to BTF enabled kernel always fails.
 | 
					// errataArm64ZBoot handles the case when upgrading from Talos < 1.8.0 on arm64 to compressed kernel.
 | 
				
			||||||
//
 | 
					func errataArm64ZBoot() {
 | 
				
			||||||
// This applies to upgrades of Talos < 1.3.0 to Talos >= 1.3.0.
 | 
						if runtime.GOARCH != "arm64" {
 | 
				
			||||||
func errataBTF() {
 | 
					 | 
				
			||||||
	_, err := os.Stat("/sys/kernel/btf/vmlinux")
 | 
					 | 
				
			||||||
	if err == nil {
 | 
					 | 
				
			||||||
		// BTF is enabled, nothing to do
 | 
					 | 
				
			||||||
		return
 | 
							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{
 | 
						if err = pkgkernel.WriteParam(&kernel.Param{
 | 
				
			||||||
		Key:   "proc.sys.kernel.kexec_load_disabled",
 | 
							Key:   "proc.sys.kernel.kexec_load_disabled",
 | 
				
			||||||
 | 
				
			|||||||
@ -228,7 +228,7 @@ func NewInstaller(ctx context.Context, cmdline *procfs.Cmdline, mode Mode, opts
 | 
				
			|||||||
//
 | 
					//
 | 
				
			||||||
//nolint:gocyclo,cyclop
 | 
					//nolint:gocyclo,cyclop
 | 
				
			||||||
func (i *Installer) Install(ctx context.Context, mode Mode) (err error) {
 | 
					func (i *Installer) Install(ctx context.Context, mode Mode) (err error) {
 | 
				
			||||||
	errataBTF()
 | 
						errataArm64ZBoot()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if mode == ModeUpgrade {
 | 
						if mode == ModeUpgrade {
 | 
				
			||||||
		if err = i.errataNetIfnames(); err != nil {
 | 
							if err = i.errataNetIfnames(); err != nil {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user