aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChuck Silvers <chs@FreeBSD.org>2024-02-13 16:15:25 +0000
committerChuck Silvers <chs@FreeBSD.org>2024-02-13 16:18:06 +0000
commitfd24a63a38d0d4cb4f5041ef232036abe09d9d4f (patch)
tree3c63e079bb8027f927b07bcec6aac05a554761c2
parentc5796f1572c82b88e8b6a2810c92f30e5ac3e118 (diff)
downloadsrc-fd24a63a38d0d4cb4f5041ef232036abe09d9d4f.tar.gz
src-fd24a63a38d0d4cb4f5041ef232036abe09d9d4f.zip
x86/ucode: add const where appropriate
Sponsored by: Netflix Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D43865
-rw-r--r--sys/x86/include/ucode.h2
-rw-r--r--sys/x86/x86/ucode.c40
2 files changed, 22 insertions, 20 deletions
diff --git a/sys/x86/include/ucode.h b/sys/x86/include/ucode.h
index cf9c756fc8f3..e97d41c89ed0 100644
--- a/sys/x86/include/ucode.h
+++ b/sys/x86/include/ucode.h
@@ -56,7 +56,7 @@ struct ucode_intel_extsig_table {
} entries[0];
};
-int ucode_intel_load(void *data, bool unsafe,
+int ucode_intel_load(const void *data, bool unsafe,
uint64_t *nrevp, uint64_t *orevp);
size_t ucode_load_bsp(uintptr_t free);
void ucode_load_ap(int cpu);
diff --git a/sys/x86/x86/ucode.c b/sys/x86/x86/ucode.c
index 1366c50f9ae5..8e9f8e113c40 100644
--- a/sys/x86/x86/ucode.c
+++ b/sys/x86/x86/ucode.c
@@ -50,14 +50,14 @@
#include <vm/vm_kern.h>
#include <vm/vm_param.h>
-static void *ucode_intel_match(uint8_t *data, size_t *len);
-static int ucode_intel_verify(struct ucode_intel_header *hdr,
+static const void *ucode_intel_match(const uint8_t *data, size_t *len);
+static int ucode_intel_verify(const struct ucode_intel_header *hdr,
size_t resid);
static struct ucode_ops {
const char *vendor;
- int (*load)(void *, bool, uint64_t *, uint64_t *);
- void *(*match)(uint8_t *, size_t *);
+ int (*load)(const void *, bool, uint64_t *, uint64_t *);
+ const void *(*match)(const uint8_t *, size_t *);
} loaders[] = {
{
.vendor = INTEL_VENDOR_ID,
@@ -67,8 +67,8 @@ static struct ucode_ops {
};
/* Selected microcode update data. */
-static void *early_ucode_data;
-static void *ucode_data;
+static const void *early_ucode_data;
+static const void *ucode_data;
static struct ucode_ops *ucode_loader;
/* Variables used for reporting success or failure. */
@@ -103,7 +103,7 @@ log_msg(void *arg __unused)
SYSINIT(ucode_log, SI_SUB_CPU, SI_ORDER_FIRST, log_msg, NULL);
int
-ucode_intel_load(void *data, bool unsafe, uint64_t *nrevp, uint64_t *orevp)
+ucode_intel_load(const void *data, bool unsafe, uint64_t *nrevp, uint64_t *orevp)
{
uint64_t nrev, orev;
uint32_t cpuid[4];
@@ -140,9 +140,10 @@ ucode_intel_load(void *data, bool unsafe, uint64_t *nrevp, uint64_t *orevp)
}
static int
-ucode_intel_verify(struct ucode_intel_header *hdr, size_t resid)
+ucode_intel_verify(const struct ucode_intel_header *hdr, size_t resid)
{
- uint32_t cksum, *data, size;
+ const uint32_t *data;
+ uint32_t cksum, size;
int i;
if (resid < sizeof(struct ucode_intel_header))
@@ -160,7 +161,7 @@ ucode_intel_verify(struct ucode_intel_header *hdr, size_t resid)
return (1);
cksum = 0;
- data = (uint32_t *)hdr;
+ data = (const uint32_t *)hdr;
for (i = 0; i < size / sizeof(uint32_t); i++)
cksum += data[i];
if (cksum != 0)
@@ -168,12 +169,12 @@ ucode_intel_verify(struct ucode_intel_header *hdr, size_t resid)
return (0);
}
-static void *
-ucode_intel_match(uint8_t *data, size_t *len)
+static const void *
+ucode_intel_match(const uint8_t *data, size_t *len)
{
- struct ucode_intel_header *hdr;
- struct ucode_intel_extsig_table *table;
- struct ucode_intel_extsig *entry;
+ const struct ucode_intel_header *hdr;
+ const struct ucode_intel_extsig_table *table;
+ const struct ucode_intel_extsig *entry;
uint64_t platformid;
size_t resid;
uint32_t data_size, flags, regs[4], sig, total_size;
@@ -186,7 +187,7 @@ ucode_intel_match(uint8_t *data, size_t *len)
flags = 1 << ((platformid >> 50) & 0x7);
for (resid = *len; resid > 0; data += total_size, resid -= total_size) {
- hdr = (struct ucode_intel_header *)data;
+ hdr = (const struct ucode_intel_header *)data;
if (ucode_intel_verify(hdr, resid) != 0) {
ucode_error = VERIFICATION_FAILED;
break;
@@ -200,8 +201,8 @@ ucode_intel_match(uint8_t *data, size_t *len)
total_size = UCODE_INTEL_DEFAULT_DATA_SIZE +
sizeof(struct ucode_intel_header);
if (data_size > total_size + sizeof(struct ucode_intel_header))
- table = (struct ucode_intel_extsig_table *)
- ((uint8_t *)(hdr + 1) + data_size);
+ table = (const struct ucode_intel_extsig_table *)
+ ((const uint8_t *)(hdr + 1) + data_size);
else
table = NULL;
@@ -317,7 +318,8 @@ ucode_load_bsp(uintptr_t free)
uint32_t regs[4];
char vendor[13];
} cpuid;
- uint8_t *addr, *fileaddr, *match;
+ const uint8_t *fileaddr, *match;
+ uint8_t *addr;
char *type;
uint64_t nrev, orev;
caddr_t file;