From: jsg Date: Sat, 22 Jul 2023 10:11:19 +0000 (+0000) Subject: BOOTARG_UCODE for AMD X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=126dac3c2c98b3b1c49d967526012b1e532e0396;p=openbsd BOOTARG_UCODE for AMD ok deraadt@ --- diff --git a/sys/arch/amd64/stand/boot/conf.c b/sys/arch/amd64/stand/boot/conf.c index 00176599d62..9e8a4a70d4b 100644 --- a/sys/arch/amd64/stand/boot/conf.c +++ b/sys/arch/amd64/stand/boot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.56 2023/04/25 10:06:12 kn Exp $ */ +/* $OpenBSD: conf.c,v 1.57 2023/07/22 10:11:19 jsg Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -41,7 +41,7 @@ #include #include -const char version[] = "3.56"; +const char version[] = "3.65"; int debug = 1; diff --git a/sys/arch/amd64/stand/cdboot/conf.c b/sys/arch/amd64/stand/cdboot/conf.c index 654825fd64c..e8272bc42d4 100644 --- a/sys/arch/amd64/stand/cdboot/conf.c +++ b/sys/arch/amd64/stand/cdboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.50 2023/04/25 10:06:12 kn Exp $ */ +/* $OpenBSD: conf.c,v 1.51 2023/07/22 10:11:19 jsg Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -42,7 +42,7 @@ #include #include -const char version[] = "3.56"; +const char version[] = "3.65"; int debug = 1; diff --git a/sys/arch/amd64/stand/efiboot/conf.c b/sys/arch/amd64/stand/efiboot/conf.c index ff714754c91..a7d10203bf3 100644 --- a/sys/arch/amd64/stand/efiboot/conf.c +++ b/sys/arch/amd64/stand/efiboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.41 2023/04/25 10:11:20 kn Exp $ */ +/* $OpenBSD: conf.c,v 1.42 2023/07/22 10:11:19 jsg Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -40,7 +40,7 @@ #include "efidev.h" #include "efipxe.h" -const char version[] = "3.64"; +const char version[] = "3.65"; #ifdef EFI_DEBUG int debug = 0; diff --git a/sys/arch/amd64/stand/efiboot/exec_i386.c b/sys/arch/amd64/stand/efiboot/exec_i386.c index e5b410472c1..b84476a2288 100644 --- a/sys/arch/amd64/stand/efiboot/exec_i386.c +++ b/sys/arch/amd64/stand/efiboot/exec_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_i386.c,v 1.10 2023/02/23 19:48:21 miod Exp $ */ +/* $OpenBSD: exec_i386.c,v 1.11 2023/07/22 10:11:19 jsg Exp $ */ /* * Copyright (c) 1997-1998 Michael Shalayeff @@ -180,7 +180,8 @@ ucode_load(void) CPUID(0, dummy, vendor[0], vendor[2], vendor[1]); vendor[3] = 0; /* NULL-terminate */ - if (strcmp((char *)vendor, "GenuineIntel") != 0) + if (strcmp((char *)vendor, "GenuineIntel") != 0 && + strcmp((char *)vendor, "AuthenticAMD") != 0) return; CPUID(1, signature, dummy, dummy, dummy); @@ -192,8 +193,22 @@ ucode_load(void) } stepping = (signature >> 0) & 0x0f; - snprintf(path, sizeof(path), "%s:/etc/firmware/intel/%02x-%02x-%02x", - cmd.bootdev, family, model, stepping); + if (strcmp((char *)vendor, "GenuineIntel") == 0) { + snprintf(path, sizeof(path), + "%s:/etc/firmware/intel/%02x-%02x-%02x", + cmd.bootdev, family, model, stepping); + } else if (strcmp((char *)vendor, "AuthenticAMD") == 0) { + if (family < 0x10) + return; + else if (family <= 0x14) + snprintf(path, sizeof(path), + "%s:/etc/firmware/amd/microcode_amd.bin", + cmd.bootdev); + else + snprintf(path, sizeof(path), + "%s:/etc/firmware/amd/microcode_amd_fam%02xh.bin", + cmd.bootdev, family); + } fd = open(path, O_RDONLY); if (fd == -1) diff --git a/sys/arch/amd64/stand/libsa/exec_i386.c b/sys/arch/amd64/stand/libsa/exec_i386.c index 1d2e14bf929..8dc0b924fb7 100644 --- a/sys/arch/amd64/stand/libsa/exec_i386.c +++ b/sys/arch/amd64/stand/libsa/exec_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_i386.c,v 1.37 2022/07/11 19:45:02 kettenis Exp $ */ +/* $OpenBSD: exec_i386.c,v 1.38 2023/07/22 10:11:19 jsg Exp $ */ /* * Copyright (c) 1997-1998 Michael Shalayeff @@ -202,7 +202,8 @@ ucode_load(void) CPUID(0, dummy, vendor[0], vendor[2], vendor[1]); vendor[3] = 0; /* NULL-terminate */ - if (strcmp((char *)vendor, "GenuineIntel") != 0) + if (strcmp((char *)vendor, "GenuineIntel") != 0 && + strcmp((char *)vendor, "AuthenticAMD") != 0) return; CPUID(1, signature, dummy, dummy, dummy); @@ -214,8 +215,22 @@ ucode_load(void) } stepping = (signature >> 0) & 0x0f; - snprintf(path, sizeof(path), "%s:/etc/firmware/intel/%02x-%02x-%02x", - cmd.bootdev, family, model, stepping); + if (strcmp((char *)vendor, "GenuineIntel") == 0) { + snprintf(path, sizeof(path), + "%s:/etc/firmware/intel/%02x-%02x-%02x", + cmd.bootdev, family, model, stepping); + } else if (strcmp((char *)vendor, "AuthenticAMD") == 0) { + if (family < 0x10) + return; + else if (family <= 0x14) + snprintf(path, sizeof(path), + "%s:/etc/firmware/amd/microcode_amd.bin", + cmd.bootdev); + else + snprintf(path, sizeof(path), + "%s:/etc/firmware/amd/microcode_amd_fam%02xh.bin", + cmd.bootdev, family); + } fd = open(path, O_RDONLY); if (fd == -1) diff --git a/sys/arch/amd64/stand/pxeboot/conf.c b/sys/arch/amd64/stand/pxeboot/conf.c index 290d50f001f..791ba5f6b1e 100644 --- a/sys/arch/amd64/stand/pxeboot/conf.c +++ b/sys/arch/amd64/stand/pxeboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.55 2023/04/25 10:06:12 kn Exp $ */ +/* $OpenBSD: conf.c,v 1.56 2023/07/22 10:11:20 jsg Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -44,7 +44,7 @@ #include "pxeboot.h" #include "pxe_net.h" -const char version[] = "3.56"; +const char version[] = "3.65"; int debug = 0; void (*sa_cleanup)(void) = pxe_shutdown; diff --git a/sys/arch/i386/stand/boot/conf.c b/sys/arch/i386/stand/boot/conf.c index f76ffad2c53..b6cb3946275 100644 --- a/sys/arch/i386/stand/boot/conf.c +++ b/sys/arch/i386/stand/boot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.77 2023/04/25 14:48:16 kn Exp $ */ +/* $OpenBSD: conf.c,v 1.78 2023/07/22 10:11:20 jsg Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -42,7 +42,7 @@ #include #include "debug.h" -const char version[] = "3.45"; +const char version[] = "3.65"; int debug = 1; diff --git a/sys/arch/i386/stand/cdboot/conf.c b/sys/arch/i386/stand/cdboot/conf.c index e18d8ba325f..5995647650f 100644 --- a/sys/arch/i386/stand/cdboot/conf.c +++ b/sys/arch/i386/stand/cdboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.44 2023/04/25 14:48:17 kn Exp $ */ +/* $OpenBSD: conf.c,v 1.45 2023/07/22 10:11:20 jsg Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -43,7 +43,7 @@ #include #include "debug.h" -const char version[] = "3.45"; +const char version[] = "3.65"; int debug = 1; void (*sa_cleanup)(void) = NULL; diff --git a/sys/arch/i386/stand/libsa/exec_i386.c b/sys/arch/i386/stand/libsa/exec_i386.c index d9e4da9db28..9bf8463edf4 100644 --- a/sys/arch/i386/stand/libsa/exec_i386.c +++ b/sys/arch/i386/stand/libsa/exec_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_i386.c,v 1.52 2022/07/07 00:56:47 daniel Exp $ */ +/* $OpenBSD: exec_i386.c,v 1.53 2023/07/22 10:11:20 jsg Exp $ */ /* * Copyright (c) 1997-1998 Michael Shalayeff @@ -190,7 +190,8 @@ ucode_load(void) CPUID(0, dummy, vendor[0], vendor[2], vendor[1]); vendor[3] = 0; /* NULL-terminate */ - if (strcmp((char *)vendor, "GenuineIntel") != 0) + if (strcmp((char *)vendor, "GenuineIntel") != 0 && + strcmp((char *)vendor, "AuthenticAMD") != 0) return; CPUID(1, signature, dummy, dummy, dummy); @@ -202,8 +203,22 @@ ucode_load(void) } stepping = (signature >> 0) & 0x0f; - snprintf(path, sizeof(path), "%s:/etc/firmware/intel/%02x-%02x-%02x", - cmd.bootdev, family, model, stepping); + if (strcmp((char *)vendor, "GenuineIntel") == 0) { + snprintf(path, sizeof(path), + "%s:/etc/firmware/intel/%02x-%02x-%02x", + cmd.bootdev, family, model, stepping); + } else if (strcmp((char *)vendor, "AuthenticAMD") == 0) { + if (family < 0x10) + return; + else if (family <= 0x14) + snprintf(path, sizeof(path), + "%s:/etc/firmware/amd/microcode_amd.bin", + cmd.bootdev); + else + snprintf(path, sizeof(path), + "%s:/etc/firmware/amd/microcode_amd_fam%02xh.bin", + cmd.bootdev, family); + } fd = open(path, O_RDONLY); if (fd == -1) diff --git a/sys/arch/i386/stand/pxeboot/conf.c b/sys/arch/i386/stand/pxeboot/conf.c index f022641757b..4958b7e3441 100644 --- a/sys/arch/i386/stand/pxeboot/conf.c +++ b/sys/arch/i386/stand/pxeboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.49 2023/04/25 14:48:17 kn Exp $ */ +/* $OpenBSD: conf.c,v 1.50 2023/07/22 10:11:20 jsg Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -45,7 +45,7 @@ #include "pxeboot.h" #include "pxe_net.h" -const char version[] = "3.45"; +const char version[] = "3.65"; int debug = 1; void (*sa_cleanup)(void) = pxe_shutdown;