Page MenuHomeFreeBSD

D17487.diff
No OneTemporary

D17487.diff

Index: head/sys/amd64/include/cpu.h
===================================================================
--- head/sys/amd64/include/cpu.h
+++ head/sys/amd64/include/cpu.h
@@ -92,6 +92,10 @@
return (rdtsc());
}
+#define MEMSET_EARLY_FUNC memset_std
+#define MEMCPY_EARLY_FUNC memcpy_std
+#define MEMMOVE_EARLY_FUNC memmove_std
+
#endif
#endif /* !_MACHINE_CPU_H_ */
Index: head/sys/conf/files
===================================================================
--- head/sys/conf/files
+++ head/sys/conf/files
@@ -3876,6 +3876,7 @@
kern/subr_counter.c standard
kern/subr_devstat.c standard
kern/subr_disk.c standard
+kern/subr_early.c standard
kern/subr_epoch.c standard
kern/subr_eventhandler.c standard
kern/subr_fattime.c standard
Index: head/sys/kern/link_elf.c
===================================================================
--- head/sys/kern/link_elf.c
+++ head/sys/kern/link_elf.c
@@ -1682,14 +1682,10 @@
{
struct elf_file eff;
elf_file_t ef;
- volatile char *c;
- size_t i;
ef = &eff;
- /* Do not use bzero/memset before ireloc is done. */
- for (c = (char *)ef, i = 0; i < sizeof(*ef); i++)
- c[i] = 0;
+ bzero_early(ef, sizeof(*ef));
ef->modptr = kmdp;
ef->dynamic = (Elf_Dyn *)&_DYNAMIC;
Index: head/sys/sys/systm.h
===================================================================
--- head/sys/sys/systm.h
+++ head/sys/sys/systm.h
@@ -324,6 +324,12 @@
int memcmp(const void *b1, const void *b2, size_t len);
#define memcmp(b1, b2, len) __builtin_memcmp((b1), (b2), (len))
+void *memset_early(void * _Nonnull buf, int c, size_t len);
+#define bzero_early(buf, len) memset_early((buf), 0, (len))
+void *memcpy_early(void * _Nonnull to, const void * _Nonnull from, size_t len);
+void *memmove_early(void * _Nonnull dest, const void * _Nonnull src, size_t n);
+#define bcopy_early(from, to, len) memmove_early((to), (from), (len))
+
int copystr(const void * _Nonnull __restrict kfaddr,
void * _Nonnull __restrict kdaddr, size_t len,
size_t * __restrict lencopied);
Index: head/sys/x86/x86/ucode.c
===================================================================
--- head/sys/x86/x86/ucode.c
+++ head/sys/x86/x86/ucode.c
@@ -355,8 +355,7 @@
if (match != NULL) {
addr = map_ucode(free, len);
/* We can't use memcpy() before ifunc resolution. */
- for (i = 0; i < len; i++)
- addr[i] = ((volatile uint8_t *)match)[i];
+ memcpy_early(addr, match, len);
match = addr;
error = ucode_loader->load(match, false, &nrev, &orev);
Index: head/sys/x86/xen/pv.c
===================================================================
--- head/sys/x86/xen/pv.c
+++ head/sys/x86/xen/pv.c
@@ -259,7 +259,7 @@
*/
kenv = (void *)(physfree + KERNBASE);
physfree += PAGE_SIZE;
- bzero(kenv, PAGE_SIZE);
+ bzero_early(kenv, PAGE_SIZE);
init_static_kenv(kenv, PAGE_SIZE);
/* Set the hooks for early functions that diverge from bare metal */
@@ -320,7 +320,7 @@
*/
kenv = (void *)(physfree + KERNBASE);
physfree += PAGE_SIZE;
- bzero(kenv, PAGE_SIZE);
+ bzero_early(kenv, PAGE_SIZE);
init_static_kenv(kenv, PAGE_SIZE);
if (start_info->modlist_paddr != 0) {

File Metadata

Mime Type
text/plain
Expires
Sun, Feb 1, 8:43 AM (2 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28324364
Default Alt Text
D17487.diff (3 KB)

Event Timeline