master
h 70 lines 2.37 KB
Raw
1 /*
2 * Definitions for cpus with variable page sizes.
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef EXEC_PAGE_VARY_H
21 #define EXEC_PAGE_VARY_H
22
23 /*
24 * For system mode, the minimum comes from the number of bits
25 * required for maximum alignment (6) and the number of bits
26 * required for TLB_FLAGS_MASK (3).
27 *
28 * For user mode, TARGET_PAGE_BITS_VARY is a hack to allow the target
29 * page size to match the host page size. Mostly, this reduces the
30 * ordinary target page size to run on a host with 4KiB pages (i.e. x86).
31 * There is no true minimum required by the implementation, but keep the
32 * same minimum as for system mode for sanity.
33 * See linux-user/mmap.c, mmap_h_lt_g and mmap_h_gt_g.
34 */
35 #define TARGET_PAGE_BITS_MIN 9
36
37 typedef struct {
38 bool decided;
39 int bits;
40 uint64_t mask;
41 } TargetPageBits;
42
43 /**
44 * set_preferred_target_page_bits:
45 * @bits: number of bits needed to represent an address within the page
46 *
47 * Set the preferred target page size (the actual target page
48 * size may be smaller than any given CPU's preference).
49 * Returns true on success, false on failure (which can only happen
50 * if this is called after the system has already finalized its
51 * choice of page size and the requested page size is smaller than that).
52 */
53 bool set_preferred_target_page_bits(int bits);
54
55 /**
56 * finalize_target_page_bits:
57 * Commit the final value set by set_preferred_target_page_bits.
58 */
59 void finalize_target_page_bits(void);
60
61 /**
62 * migration_legacy_page_bits
63 *
64 * For migration compatibility with qemu v2.9, prior to the introduction
65 * of the configuration/target-page-bits section, return the value of
66 * TARGET_PAGE_BITS that the target had then.
67 */
68 int migration_legacy_page_bits(void);
69
70 #endif /* EXEC_PAGE_VARY_H */