/src/unicorn/qemu/exec-vary.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Variable page size handling |
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 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 | | #include "qemu/osdep.h" |
21 | | #include "qemu-common.h" |
22 | | |
23 | | #define IN_EXEC_VARY 1 |
24 | | |
25 | | #include "exec/exec-all.h" |
26 | | |
27 | | #include <uc_priv.h> |
28 | | |
29 | | bool set_preferred_target_page_bits(struct uc_struct *uc, int bits) |
30 | 0 | { |
31 | | /* |
32 | | * The target page size is the lowest common denominator for all |
33 | | * the CPUs in the system, so we can only make it smaller, never |
34 | | * larger. And we can't make it smaller once we've committed to |
35 | | * a particular size. |
36 | | */ |
37 | | #ifdef TARGET_PAGE_BITS_VARY |
38 | | //assert(bits >= TARGET_PAGE_BITS_MIN); |
39 | 0 | if (uc->init_target_page == NULL) { |
40 | 0 | uc->init_target_page = calloc(1, sizeof(TargetPageBits)); |
41 | 0 | } else { |
42 | 0 | return false; |
43 | 0 | } |
44 | | |
45 | 0 | if (bits < TARGET_PAGE_BITS_MIN) { |
46 | 0 | return false; |
47 | 0 | } |
48 | | |
49 | 0 | if (uc->init_target_page->bits == 0 || uc->init_target_page->bits > bits) { |
50 | 0 | if (uc->init_target_page->decided) { |
51 | 0 | return false; |
52 | 0 | } |
53 | 0 | uc->init_target_page->bits = bits; |
54 | 0 | } |
55 | 0 | #endif |
56 | 0 | return true; |
57 | 0 | } Unexecuted instantiation: set_preferred_target_page_bits_x86_64 Unexecuted instantiation: set_preferred_target_page_bits_arm Unexecuted instantiation: set_preferred_target_page_bits_aarch64 Unexecuted instantiation: set_preferred_target_page_bits_m68k Unexecuted instantiation: set_preferred_target_page_bits_mips Unexecuted instantiation: set_preferred_target_page_bits_mipsel Unexecuted instantiation: set_preferred_target_page_bits_mips64 Unexecuted instantiation: set_preferred_target_page_bits_mips64el Unexecuted instantiation: set_preferred_target_page_bits_sparc Unexecuted instantiation: set_preferred_target_page_bits_sparc64 Unexecuted instantiation: set_preferred_target_page_bits_ppc Unexecuted instantiation: set_preferred_target_page_bits_ppc64 Unexecuted instantiation: set_preferred_target_page_bits_riscv32 Unexecuted instantiation: set_preferred_target_page_bits_riscv64 Unexecuted instantiation: set_preferred_target_page_bits_s390x Unexecuted instantiation: set_preferred_target_page_bits_tricore |
58 | | |
59 | | void finalize_target_page_bits(struct uc_struct *uc) |
60 | 185k | { |
61 | | #ifdef TARGET_PAGE_BITS_VARY |
62 | 107k | if (uc->init_target_page == NULL) { |
63 | 107k | uc->init_target_page = calloc(1, sizeof(TargetPageBits)); |
64 | 107k | } else { |
65 | 0 | return; |
66 | 0 | } |
67 | | |
68 | 107k | if (uc->target_bits != 0) { |
69 | 0 | uc->init_target_page->bits = uc->target_bits; |
70 | 0 | } |
71 | | |
72 | 107k | if (uc->init_target_page->bits == 0) { |
73 | 107k | uc->init_target_page->bits = TARGET_PAGE_BITS_MIN; |
74 | 107k | } |
75 | | uc->init_target_page->mask = ((target_ulong)-1) << uc->init_target_page->bits; |
76 | | uc->init_target_page->decided = true; |
77 | | |
78 | | /* |
79 | | * For the benefit of an -flto build, prevent the compiler from |
80 | | * hoisting a read from target_page before we finish initializing. |
81 | | */ |
82 | | barrier(); |
83 | | #endif |
84 | 107k | } finalize_target_page_bits_x86_64 Line | Count | Source | 60 | 33.3k | { | 61 | | #ifdef TARGET_PAGE_BITS_VARY | 62 | | if (uc->init_target_page == NULL) { | 63 | | uc->init_target_page = calloc(1, sizeof(TargetPageBits)); | 64 | | } else { | 65 | | return; | 66 | | } | 67 | | | 68 | | if (uc->target_bits != 0) { | 69 | | uc->init_target_page->bits = uc->target_bits; | 70 | | } | 71 | | | 72 | | if (uc->init_target_page->bits == 0) { | 73 | | uc->init_target_page->bits = TARGET_PAGE_BITS_MIN; | 74 | | } | 75 | | uc->init_target_page->mask = ((target_ulong)-1) << uc->init_target_page->bits; | 76 | | uc->init_target_page->decided = true; | 77 | | | 78 | | /* | 79 | | * For the benefit of an -flto build, prevent the compiler from | 80 | | * hoisting a read from target_page before we finish initializing. | 81 | | */ | 82 | | barrier(); | 83 | | #endif | 84 | 33.3k | } |
finalize_target_page_bits_arm Line | Count | Source | 60 | 40.3k | { | 61 | 40.3k | #ifdef TARGET_PAGE_BITS_VARY | 62 | 40.3k | if (uc->init_target_page == NULL) { | 63 | 40.3k | uc->init_target_page = calloc(1, sizeof(TargetPageBits)); | 64 | 40.3k | } else { | 65 | 0 | return; | 66 | 0 | } | 67 | | | 68 | 40.3k | if (uc->target_bits != 0) { | 69 | 0 | uc->init_target_page->bits = uc->target_bits; | 70 | 0 | } | 71 | | | 72 | 40.3k | if (uc->init_target_page->bits == 0) { | 73 | 40.3k | uc->init_target_page->bits = TARGET_PAGE_BITS_MIN; | 74 | 40.3k | } | 75 | 40.3k | uc->init_target_page->mask = ((target_ulong)-1) << uc->init_target_page->bits; | 76 | 40.3k | uc->init_target_page->decided = true; | 77 | | | 78 | | /* | 79 | | * For the benefit of an -flto build, prevent the compiler from | 80 | | * hoisting a read from target_page before we finish initializing. | 81 | | */ | 82 | 40.3k | barrier(); | 83 | 40.3k | #endif | 84 | 40.3k | } |
finalize_target_page_bits_aarch64 Line | Count | Source | 60 | 67.1k | { | 61 | 67.1k | #ifdef TARGET_PAGE_BITS_VARY | 62 | 67.1k | if (uc->init_target_page == NULL) { | 63 | 67.1k | uc->init_target_page = calloc(1, sizeof(TargetPageBits)); | 64 | 67.1k | } else { | 65 | 0 | return; | 66 | 0 | } | 67 | | | 68 | 67.1k | if (uc->target_bits != 0) { | 69 | 0 | uc->init_target_page->bits = uc->target_bits; | 70 | 0 | } | 71 | | | 72 | 67.1k | if (uc->init_target_page->bits == 0) { | 73 | 67.1k | uc->init_target_page->bits = TARGET_PAGE_BITS_MIN; | 74 | 67.1k | } | 75 | 67.1k | uc->init_target_page->mask = ((target_ulong)-1) << uc->init_target_page->bits; | 76 | 67.1k | uc->init_target_page->decided = true; | 77 | | | 78 | | /* | 79 | | * For the benefit of an -flto build, prevent the compiler from | 80 | | * hoisting a read from target_page before we finish initializing. | 81 | | */ | 82 | 67.1k | barrier(); | 83 | 67.1k | #endif | 84 | 67.1k | } |
finalize_target_page_bits_m68k Line | Count | Source | 60 | 6.10k | { | 61 | | #ifdef TARGET_PAGE_BITS_VARY | 62 | | if (uc->init_target_page == NULL) { | 63 | | uc->init_target_page = calloc(1, sizeof(TargetPageBits)); | 64 | | } else { | 65 | | return; | 66 | | } | 67 | | | 68 | | if (uc->target_bits != 0) { | 69 | | uc->init_target_page->bits = uc->target_bits; | 70 | | } | 71 | | | 72 | | if (uc->init_target_page->bits == 0) { | 73 | | uc->init_target_page->bits = TARGET_PAGE_BITS_MIN; | 74 | | } | 75 | | uc->init_target_page->mask = ((target_ulong)-1) << uc->init_target_page->bits; | 76 | | uc->init_target_page->decided = true; | 77 | | | 78 | | /* | 79 | | * For the benefit of an -flto build, prevent the compiler from | 80 | | * hoisting a read from target_page before we finish initializing. | 81 | | */ | 82 | | barrier(); | 83 | | #endif | 84 | 6.10k | } |
finalize_target_page_bits_mips Line | Count | Source | 60 | 7.40k | { | 61 | | #ifdef TARGET_PAGE_BITS_VARY | 62 | | if (uc->init_target_page == NULL) { | 63 | | uc->init_target_page = calloc(1, sizeof(TargetPageBits)); | 64 | | } else { | 65 | | return; | 66 | | } | 67 | | | 68 | | if (uc->target_bits != 0) { | 69 | | uc->init_target_page->bits = uc->target_bits; | 70 | | } | 71 | | | 72 | | if (uc->init_target_page->bits == 0) { | 73 | | uc->init_target_page->bits = TARGET_PAGE_BITS_MIN; | 74 | | } | 75 | | uc->init_target_page->mask = ((target_ulong)-1) << uc->init_target_page->bits; | 76 | | uc->init_target_page->decided = true; | 77 | | | 78 | | /* | 79 | | * For the benefit of an -flto build, prevent the compiler from | 80 | | * hoisting a read from target_page before we finish initializing. | 81 | | */ | 82 | | barrier(); | 83 | | #endif | 84 | 7.40k | } |
finalize_target_page_bits_mipsel Line | Count | Source | 60 | 11.2k | { | 61 | | #ifdef TARGET_PAGE_BITS_VARY | 62 | | if (uc->init_target_page == NULL) { | 63 | | uc->init_target_page = calloc(1, sizeof(TargetPageBits)); | 64 | | } else { | 65 | | return; | 66 | | } | 67 | | | 68 | | if (uc->target_bits != 0) { | 69 | | uc->init_target_page->bits = uc->target_bits; | 70 | | } | 71 | | | 72 | | if (uc->init_target_page->bits == 0) { | 73 | | uc->init_target_page->bits = TARGET_PAGE_BITS_MIN; | 74 | | } | 75 | | uc->init_target_page->mask = ((target_ulong)-1) << uc->init_target_page->bits; | 76 | | uc->init_target_page->decided = true; | 77 | | | 78 | | /* | 79 | | * For the benefit of an -flto build, prevent the compiler from | 80 | | * hoisting a read from target_page before we finish initializing. | 81 | | */ | 82 | | barrier(); | 83 | | #endif | 84 | 11.2k | } |
Unexecuted instantiation: finalize_target_page_bits_mips64 Unexecuted instantiation: finalize_target_page_bits_mips64el finalize_target_page_bits_sparc Line | Count | Source | 60 | 43 | { | 61 | | #ifdef TARGET_PAGE_BITS_VARY | 62 | | if (uc->init_target_page == NULL) { | 63 | | uc->init_target_page = calloc(1, sizeof(TargetPageBits)); | 64 | | } else { | 65 | | return; | 66 | | } | 67 | | | 68 | | if (uc->target_bits != 0) { | 69 | | uc->init_target_page->bits = uc->target_bits; | 70 | | } | 71 | | | 72 | | if (uc->init_target_page->bits == 0) { | 73 | | uc->init_target_page->bits = TARGET_PAGE_BITS_MIN; | 74 | | } | 75 | | uc->init_target_page->mask = ((target_ulong)-1) << uc->init_target_page->bits; | 76 | | uc->init_target_page->decided = true; | 77 | | | 78 | | /* | 79 | | * For the benefit of an -flto build, prevent the compiler from | 80 | | * hoisting a read from target_page before we finish initializing. | 81 | | */ | 82 | | barrier(); | 83 | | #endif | 84 | 43 | } |
Unexecuted instantiation: finalize_target_page_bits_sparc64 Unexecuted instantiation: finalize_target_page_bits_ppc Unexecuted instantiation: finalize_target_page_bits_ppc64 Unexecuted instantiation: finalize_target_page_bits_riscv32 Unexecuted instantiation: finalize_target_page_bits_riscv64 finalize_target_page_bits_s390x Line | Count | Source | 60 | 19.3k | { | 61 | | #ifdef TARGET_PAGE_BITS_VARY | 62 | | if (uc->init_target_page == NULL) { | 63 | | uc->init_target_page = calloc(1, sizeof(TargetPageBits)); | 64 | | } else { | 65 | | return; | 66 | | } | 67 | | | 68 | | if (uc->target_bits != 0) { | 69 | | uc->init_target_page->bits = uc->target_bits; | 70 | | } | 71 | | | 72 | | if (uc->init_target_page->bits == 0) { | 73 | | uc->init_target_page->bits = TARGET_PAGE_BITS_MIN; | 74 | | } | 75 | | uc->init_target_page->mask = ((target_ulong)-1) << uc->init_target_page->bits; | 76 | | uc->init_target_page->decided = true; | 77 | | | 78 | | /* | 79 | | * For the benefit of an -flto build, prevent the compiler from | 80 | | * hoisting a read from target_page before we finish initializing. | 81 | | */ | 82 | | barrier(); | 83 | | #endif | 84 | 19.3k | } |
Unexecuted instantiation: finalize_target_page_bits_tricore |