Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/sys/arch/x86 Pull up following revision(s) (requested by ...
details: https://anonhg.NetBSD.org/src/rev/68dbc0ab2891
branches: netbsd-9
changeset: 371818:68dbc0ab2891
user: martin <martin%NetBSD.org@localhost>
date: Tue Oct 11 18:05:44 2022 +0000
description:
Pull up following revision(s) (requested by msaitoh in ticket #1538):
sys/arch/x86/include/cpu_ucode.h: revision 1.5
sys/arch/x86/x86/cpu_ucode_intel.c: revision 1.19
sys/arch/x86/x86/cpu_ucode_intel.c: revision 1.20
Add missing newline in a message. KNF.
Verify checksum of the extended signature table.
diffstat:
sys/arch/x86/include/cpu_ucode.h | 15 ++++----
sys/arch/x86/x86/cpu_ucode_intel.c | 61 +++++++++++++++++++------------------
2 files changed, 39 insertions(+), 37 deletions(-)
diffs (153 lines):
diff -r ac7e829b77e7 -r 68dbc0ab2891 sys/arch/x86/include/cpu_ucode.h
--- a/sys/arch/x86/include/cpu_ucode.h Tue Oct 11 17:51:18 2022 +0000
+++ b/sys/arch/x86/include/cpu_ucode.h Tue Oct 11 18:05:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_ucode.h,v 1.4 2018/03/17 15:56:32 christos Exp $ */
+/* $NetBSD: cpu_ucode.h,v 1.4.6.1 2022/10/11 18:05:44 martin Exp $ */
/*
* Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -69,17 +69,16 @@
uint32_t uh_reserved[3];
};
+struct intel1_ucode_ext_table {
+ uint32_t uet_count;
+ uint32_t uet_checksum;
+ uint32_t uet_reserved[3];
+};
+
struct intel1_ucode_proc_signature {
uint32_t ups_signature;
uint32_t ups_proc_flags;
uint32_t ups_checksum;
};
-struct intel1_ucode_ext_table {
- uint32_t uet_count;
- uint32_t uet_checksum;
- uint32_t uet_reserved[3];
- struct intel1_ucode_proc_signature uet_proc_sig[1];
-};
-
#endif
diff -r ac7e829b77e7 -r 68dbc0ab2891 sys/arch/x86/x86/cpu_ucode_intel.c
--- a/sys/arch/x86/x86/cpu_ucode_intel.c Tue Oct 11 17:51:18 2022 +0000
+++ b/sys/arch/x86/x86/cpu_ucode_intel.c Tue Oct 11 18:05:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_ucode_intel.c,v 1.17 2019/05/10 18:21:01 maxv Exp $ */
+/* $NetBSD: cpu_ucode_intel.c,v 1.17.2.1 2022/10/11 18:05:44 martin Exp $ */
/*
* Copyright (c) 2012, 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_ucode_intel.c,v 1.17 2019/05/10 18:21:01 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_ucode_intel.c,v 1.17.2.1 2022/10/11 18:05:44 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_xen.h"
@@ -111,63 +111,65 @@
cpu_ucode_intel_verify(struct cpu_ucode_softc *sc,
struct intel1_ucode_header *buf)
{
+ struct intel1_ucode_ext_table *ehdr;
uint32_t data_size, total_size, payload_size, ext_size;
uint32_t sum;
+ uint32_t *p;
int i;
if ((buf->uh_header_ver != 1) || (buf->uh_loader_rev != 1))
return EINVAL;
- /*
- * Data size.
- */
- if (buf->uh_data_size == 0) {
+ /* Data size. */
+ if (buf->uh_data_size == 0)
data_size = 2000;
- } else {
+ else
data_size = buf->uh_data_size;
- }
if ((data_size % 4) != 0)
return EINVAL;
if (data_size > sc->sc_blobsize)
return EINVAL;
- /*
- * Total size.
- */
- if (buf->uh_total_size == 0) {
+ /* Total size. */
+ if (buf->uh_total_size == 0)
total_size = data_size + 48;
- } else {
+ else
total_size = buf->uh_total_size;
- }
if ((total_size % 1024) != 0)
return EINVAL;
if (total_size > sc->sc_blobsize)
return EINVAL;
- /*
- * Payload size.
- */
+ /* Payload size. */
payload_size = data_size + 48;
if (payload_size > sc->sc_blobsize)
return EINVAL;
- /*
- * Verify checksum of update data and header. Exclude extended
- * signature.
- */
+ /* Verify checksum of update data and header(s). */
sum = 0;
- for (i = 0; i < (payload_size / sizeof(uint32_t)); i++) {
- sum += *((uint32_t *)buf + i);
- }
+ p = (uint32_t *)buf;
+ for (i = 0; i < (payload_size / sizeof(uint32_t)); i++)
+ sum += p[i];
if (sum != 0)
return EINVAL;
- /*
- * Extended table size. Ignored for now.
- */
ext_size = total_size - payload_size;
if (ext_size > 0) {
- printf("This image has extended signature table.");
+ /* This image has extended signature table. */
+ ehdr = (struct intel1_ucode_ext_table *)
+ ((uint8_t *)buf + sizeof(struct intel1_ucode_header) +
+ data_size);
+ payload_size =
+ sizeof(struct intel1_ucode_ext_table) +
+ sizeof(struct intel1_ucode_proc_signature) *
+ ehdr->uet_count;
+
+ sum = 0;
+ p = (uint32_t *)ehdr;
+ for (i = 0; i < (payload_size / sizeof(uint32_t)); i++)
+ sum += p[i];
+ if (sum != 0)
+ return EINVAL;
}
return 0;
@@ -198,7 +200,8 @@
/* Make the buffer 16 byte aligned. */
newbufsize = sc->sc_blobsize + 15;
uha = kmem_alloc(newbufsize, KM_SLEEP);
- uh = (struct intel1_ucode_header *)roundup2((uintptr_t)uha, 16);
+ uh =
+ (struct intel1_ucode_header *)roundup2((uintptr_t)uha, 16);
memcpy(uh, sc->sc_blob, sc->sc_blobsize);
}
Home |
Main Index |
Thread Index |
Old Index