Coverage Report

Created: 2026-06-30 07:08

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/unicorn/qemu/exec-vary.c
Line
Count
Source
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
212k
{
61
#ifdef TARGET_PAGE_BITS_VARY
62
126k
    if (uc->init_target_page == NULL) {
63
126k
        uc->init_target_page = calloc(1, sizeof(TargetPageBits));
64
126k
    } else {
65
0
        return;
66
0
    }
67
68
126k
    if (uc->target_bits != 0) {
69
0
        uc->init_target_page->bits = uc->target_bits;
70
0
    }
71
72
126k
    if (uc->init_target_page->bits == 0) {
73
126k
        uc->init_target_page->bits = TARGET_PAGE_BITS_MIN;
74
126k
    }
75
126k
    uc->init_target_page->mask = ((target_ulong)-1) << uc->init_target_page->bits;
76
126k
    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
126k
}
finalize_target_page_bits_x86_64
Line
Count
Source
60
35.0k
{
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
35.0k
}
finalize_target_page_bits_arm
Line
Count
Source
60
55.7k
{
61
55.7k
#ifdef TARGET_PAGE_BITS_VARY
62
55.7k
    if (uc->init_target_page == NULL) {
63
55.7k
        uc->init_target_page = calloc(1, sizeof(TargetPageBits));
64
55.7k
    } else {
65
0
        return;
66
0
    }
67
68
55.7k
    if (uc->target_bits != 0) {
69
0
        uc->init_target_page->bits = uc->target_bits;
70
0
    }
71
72
55.7k
    if (uc->init_target_page->bits == 0) {
73
55.7k
        uc->init_target_page->bits = TARGET_PAGE_BITS_MIN;
74
55.7k
    }
75
55.7k
    uc->init_target_page->mask = ((target_ulong)-1) << uc->init_target_page->bits;
76
55.7k
    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
55.7k
    barrier();
83
55.7k
#endif
84
55.7k
}
finalize_target_page_bits_aarch64
Line
Count
Source
60
70.4k
{
61
70.4k
#ifdef TARGET_PAGE_BITS_VARY
62
70.4k
    if (uc->init_target_page == NULL) {
63
70.4k
        uc->init_target_page = calloc(1, sizeof(TargetPageBits));
64
70.4k
    } else {
65
0
        return;
66
0
    }
67
68
70.4k
    if (uc->target_bits != 0) {
69
0
        uc->init_target_page->bits = uc->target_bits;
70
0
    }
71
72
70.4k
    if (uc->init_target_page->bits == 0) {
73
70.4k
        uc->init_target_page->bits = TARGET_PAGE_BITS_MIN;
74
70.4k
    }
75
70.4k
    uc->init_target_page->mask = ((target_ulong)-1) << uc->init_target_page->bits;
76
70.4k
    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
70.4k
    barrier();
83
70.4k
#endif
84
70.4k
}
finalize_target_page_bits_m68k
Line
Count
Source
60
4
{
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
4
}
finalize_target_page_bits_mips
Line
Count
Source
60
10.5k
{
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
10.5k
}
finalize_target_page_bits_mipsel
Line
Count
Source
60
11.1k
{
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.1k
}
Unexecuted instantiation: finalize_target_page_bits_mips64
Unexecuted instantiation: finalize_target_page_bits_mips64el
finalize_target_page_bits_sparc
Line
Count
Source
60
33
{
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
}
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
29.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
29.2k
}
Unexecuted instantiation: finalize_target_page_bits_tricore