mirror of
https://github.com/ipxe/ipxe
synced 2026-04-04 03:00:20 +03:00
[riscv] Hold virtual address offset in the thread pointer register
iPXE does not make use of any thread-local storage. Use the otherwise
unused thread pointer register ("tp") to hold the current value of
the virtual address offset, rather than using a global variable.
This ensures that virt_offset can be made valid even during very early
initialisation (when iPXE may be executing directly from read-only
memory and so cannot update a global variable).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -29,6 +29,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#include <byteswap.h>
|
||||
#include <ipxe/netdevice.h>
|
||||
#include <ipxe/image.h>
|
||||
#include <ipxe/uaccess.h>
|
||||
#include <ipxe/umalloc.h>
|
||||
#include <ipxe/fdt.h>
|
||||
|
||||
@@ -734,8 +735,9 @@ int fdt_parse ( struct fdt *fdt, struct fdt_header *hdr, size_t max_len ) {
|
||||
fdt->len, max_len );
|
||||
goto err;
|
||||
}
|
||||
DBGC ( fdt, "FDT version %d at %p+%#04zx\n",
|
||||
be32_to_cpu ( hdr->version ), fdt->hdr, fdt->len );
|
||||
DBGC ( fdt, "FDT version %d at %p+%#04zx (phys %#08lx)\n",
|
||||
be32_to_cpu ( hdr->version ), fdt->hdr, fdt->len,
|
||||
virt_to_phys ( hdr ) );
|
||||
|
||||
/* Check signature */
|
||||
if ( hdr->magic != cpu_to_be32 ( FDT_MAGIC ) ) {
|
||||
|
||||
@@ -34,3 +34,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
/* Flat address space user access API */
|
||||
PROVIDE_UACCESS_INLINE ( flat, phys_to_virt );
|
||||
PROVIDE_UACCESS_INLINE ( flat, virt_to_phys );
|
||||
|
||||
/* Virtual address offset user access API */
|
||||
PROVIDE_UACCESS_INLINE ( offset, phys_to_virt );
|
||||
PROVIDE_UACCESS_INLINE ( offset, virt_to_phys );
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <ipxe/uaccess.h>
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Virtual offset memory model
|
||||
*
|
||||
*/
|
||||
|
||||
PROVIDE_UACCESS_INLINE ( offset, phys_to_virt );
|
||||
PROVIDE_UACCESS_INLINE ( offset, virt_to_phys );
|
||||
Reference in New Issue
Block a user