1 /*
2 * x86 memory access helpers
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 #include "qemu/osdep.h"
21 #include "cpu.h"
22 #include "exec/helper-proto.h"
23 #include "accel/tcg/cpu-ldst.h"
24 #include "qemu/int128.h"
25 #include "qemu/atomic128.h"
26 #include "tcg/tcg.h"
27 #include "helper-tcg.h"
28
helper_boundw(CPUX86State * env,target_ulong a0,int v)29 void helper_boundw(CPUX86State *env, target_ulong a0, int v)
30 {
31 int low, high;
32
33 low = cpu_ldsw_data_ra(env, a0, GETPC());
34 high = cpu_ldsw_data_ra(env, a0 + 2, GETPC());
35 v = (int16_t)v;
36 if (v < low || v > high) {
37 if (env->hflags & HF_MPX_EN_MASK) {
38 env->bndcs_regs.sts = 0;
39 }
40 raise_exception_ra(env, EXCP05_BOUND, GETPC());
41 }
42 }
43
helper_boundl(CPUX86State * env,target_ulong a0,int v)44 void helper_boundl(CPUX86State *env, target_ulong a0, int v)
45 {
46 int low, high;
47
48 low = cpu_ldl_data_ra(env, a0, GETPC());
49 high = cpu_ldl_data_ra(env, a0 + 4, GETPC());
50 if (v < low || v > high) {
51 if (env->hflags & HF_MPX_EN_MASK) {
52 env->bndcs_regs.sts = 0;
53 }
54 raise_exception_ra(env, EXCP05_BOUND, GETPC());
55 }
56 }
57