1111
1212/*
1313 * Copyright 2019 Joyent, Inc.
14+ * Copyright 2025 Edgecast Cloud LLC.
1415 */
1516
1617/*
4344
4445static const char * ucc_progname ;
4546static const char * amd_ucodedir = "platform/i86pc/ucode/AuthenticAMD" ;
47+ static const char * amd_ucodedir_fallback =
48+ "platform/i86pc/ucode/AuthenticAMD/fallback" ;
4649static const char * intc_ucodedir = "platform/i86pc/ucode/GenuineIntel" ;
4750
4851typedef struct ucodecheck {
@@ -82,17 +85,23 @@ ucc_manifest_cb(manifest_ent_t *me, void *arg)
8285
8386 static size_t intc_len = 0 ;
8487 static size_t amd_len = 0 ;
88+ static size_t amd_fallback_len = 0 ;
8589
8690 if (amd_len == 0 ) {
8791 amd_len = strlen (amd_ucodedir );
8892 }
8993
94+ if (amd_fallback_len == 0 ) {
95+ amd_fallback_len = strlen (amd_ucodedir_fallback );
96+ }
97+
9098 if (intc_len == 0 ) {
9199 intc_len = strlen (intc_ucodedir );
92100 }
93101
94102 if (strncmp (amd_ucodedir , me -> me_name , amd_len ) != 0 &&
95- strncmp (intc_ucodedir , me -> me_name , intc_len ) != 0 ) {
103+ strncmp (amd_ucodedir_fallback , me -> me_name , amd_fallback_len ) != 0
104+ && strncmp (intc_ucodedir , me -> me_name , intc_len ) != 0 ) {
96105 return (MECB_NEXT );
97106 }
98107
@@ -139,6 +148,15 @@ ucc_read_proto(ucodecheck_t *ucc, const char *dir)
139148 struct dirent * dp ;
140149
141150 if ((dirfd = openat (ucc -> ucc_proto_dir , dir , O_RDONLY )) < 0 ) {
151+ /*
152+ * If it's the AMD fallback directory, return nicely and let
153+ * ucc_check_proto() do its thing instead.
154+ */
155+ if (dir == amd_ucodedir_fallback ) {
156+ fprintf (stderr ,
157+ " (AMD fallback directory not in proto.) " );
158+ return ;
159+ }
142160 err (EXIT_FAILURE , "failed to open proto directory %s, current "
143161 "root is at %s" , dir , ucc -> ucc_proto_path );
144162 }
@@ -152,11 +170,16 @@ ucc_read_proto(ucodecheck_t *ucc, const char *dir)
152170 ucode_ent_t * ent ;
153171 avl_index_t where ;
154172
173+ /* Skip the obvious directory entries. */
155174 if (strcmp (dp -> d_name , "." ) == 0 )
156175 continue ;
157176 if (strcmp (dp -> d_name , ".." ) == 0 )
158177 continue ;
159178
179+ /* Skip (special-case) the AMD fallback directory too. */
180+ if (dir == amd_ucodedir && strcmp (dp -> d_name , "fallback" ) == 0 )
181+ continue ;
182+
160183 if (fstatat (dirfd , dp -> d_name , & st , AT_SYMLINK_NOFOLLOW ) != 0 ) {
161184 err (EXIT_FAILURE , "failed to stat \"%s/%s\"" , dir ,
162185 dp -> d_name );
@@ -323,6 +346,7 @@ main(int argc, char *argv[])
323346 }
324347
325348 ucc_read_proto (& ucc , amd_ucodedir );
349+ ucc_read_proto (& ucc , amd_ucodedir_fallback );
326350 ucc_read_proto (& ucc , intc_ucodedir );
327351
328352 ucc_check_proto (& ucc );
0 commit comments