2003-08-10 21:35:13 +00:00
|
|
|
/*
|
|
|
|
|
* common defines for all CPUs
|
2007-09-16 21:08:06 +00:00
|
|
|
*
|
2003-08-10 21:35:13 +00:00
|
|
|
* Copyright (c) 2003 Fabrice Bellard
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
2020-10-23 12:33:53 +00:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2003-08-10 21:35:13 +00:00
|
|
|
*
|
|
|
|
|
* This library 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
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2009-07-16 20:47:01 +00:00
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2003-08-10 21:35:13 +00:00
|
|
|
*/
|
|
|
|
|
#ifndef CPU_DEFS_H
|
|
|
|
|
#define CPU_DEFS_H
|
|
|
|
|
|
2007-11-17 17:14:51 +00:00
|
|
|
#ifndef NEED_CPU_H
|
|
|
|
|
#error cpu.h included from common code
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-03-15 15:36:13 +01:00
|
|
|
#include "qemu/host-utils.h"
|
2018-10-09 13:45:56 -04:00
|
|
|
#include "qemu/thread.h"
|
2013-05-28 14:02:38 +02:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2012-12-17 18:19:49 +01:00
|
|
|
#include "exec/hwaddr.h"
|
2013-05-28 14:02:38 +02:00
|
|
|
#endif
|
2015-04-26 16:49:24 +01:00
|
|
|
#include "exec/memattrs.h"
|
2019-07-09 17:20:52 +02:00
|
|
|
#include "hw/core/cpu.h"
|
2003-08-10 21:35:13 +00:00
|
|
|
|
2019-03-22 11:51:19 -07:00
|
|
|
#include "cpu-param.h"
|
|
|
|
|
|
2004-01-24 15:26:06 +00:00
|
|
|
#ifndef TARGET_LONG_BITS
|
2019-03-22 11:51:19 -07:00
|
|
|
# error TARGET_LONG_BITS must be defined in cpu-param.h
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef TARGET_PHYS_ADDR_SPACE_BITS
|
|
|
|
|
# error TARGET_PHYS_ADDR_SPACE_BITS must be defined in cpu-param.h
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef TARGET_VIRT_ADDR_SPACE_BITS
|
|
|
|
|
# error TARGET_VIRT_ADDR_SPACE_BITS must be defined in cpu-param.h
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef TARGET_PAGE_BITS
|
|
|
|
|
# ifdef TARGET_PAGE_BITS_VARY
|
|
|
|
|
# ifndef TARGET_PAGE_BITS_MIN
|
|
|
|
|
# error TARGET_PAGE_BITS_MIN must be defined in cpu-param.h
|
|
|
|
|
# endif
|
|
|
|
|
# else
|
|
|
|
|
# error TARGET_PAGE_BITS must be defined in cpu-param.h
|
|
|
|
|
# endif
|
2004-01-24 15:26:06 +00:00
|
|
|
#endif
|
|
|
|
|
|
2023-03-02 18:58:00 -08:00
|
|
|
#include "exec/target_long.h"
|
2004-01-24 15:26:06 +00:00
|
|
|
|
2023-06-06 01:02:16 +02:00
|
|
|
#if defined(CONFIG_SOFTMMU) && defined(CONFIG_TCG)
|
2019-01-16 12:01:13 -05:00
|
|
|
#define CPU_TLB_DYN_MIN_BITS 6
|
|
|
|
|
#define CPU_TLB_DYN_DEFAULT_BITS 8
|
|
|
|
|
|
|
|
|
|
# if HOST_LONG_BITS == 32
|
|
|
|
|
/* Make sure we do not require a double-word shift for the TLB load */
|
|
|
|
|
# define CPU_TLB_DYN_MAX_BITS (32 - TARGET_PAGE_BITS)
|
|
|
|
|
# else /* HOST_LONG_BITS == 64 */
|
|
|
|
|
/*
|
|
|
|
|
* Assuming TARGET_PAGE_BITS==12, with 2**22 entries we can cover 2**(22+12) ==
|
|
|
|
|
* 2**34 == 16G of address space. This is roughly what one would expect a
|
|
|
|
|
* TLB to cover in a modern (as of 2018) x86_64 CPU. For instance, Intel
|
|
|
|
|
* Skylake's Level-2 STLB has 16 1G entries.
|
|
|
|
|
* Also, make sure we do not size the TLB past the guest's address space.
|
|
|
|
|
*/
|
2020-06-25 11:26:02 -05:00
|
|
|
# ifdef TARGET_PAGE_BITS_VARY
|
|
|
|
|
# define CPU_TLB_DYN_MAX_BITS \
|
2019-01-16 12:01:13 -05:00
|
|
|
MIN(22, TARGET_VIRT_ADDR_SPACE_BITS - TARGET_PAGE_BITS)
|
2020-06-25 11:26:02 -05:00
|
|
|
# else
|
|
|
|
|
# define CPU_TLB_DYN_MAX_BITS \
|
|
|
|
|
MIN_CONST(22, TARGET_VIRT_ADDR_SPACE_BITS - TARGET_PAGE_BITS)
|
|
|
|
|
# endif
|
2019-01-16 12:01:13 -05:00
|
|
|
# endif
|
|
|
|
|
|
2023-06-06 01:02:16 +02:00
|
|
|
#endif /* CONFIG_SOFTMMU && CONFIG_TCG */
|
2023-02-17 17:11:36 -03:00
|
|
|
|
2003-08-10 21:35:13 +00:00
|
|
|
#endif
|