xref: /qemu/target/i386/tcg/mem_helper.c (revision 5ac034b1)
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 "exec/exec-all.h"
24 #include "exec/cpu_ldst.h"
25 #include "qemu/int128.h"
26 #include "qemu/atomic128.h"
27 #include "tcg/tcg.h"
28 #include "helper-tcg.h"
29 
30 void helper_boundw(CPUX86State *env, target_ulong a0, int v)
31 {
32     int low, high;
33 
34     low = cpu_ldsw_data_ra(env, a0, GETPC());
35     high = cpu_ldsw_data_ra(env, a0 + 2, GETPC());
36     v = (int16_t)v;
37     if (v < low || v > high) {
38         if (env->hflags & HF_MPX_EN_MASK) {
39             env->bndcs_regs.sts = 0;
40         }
41         raise_exception_ra(env, EXCP05_BOUND, GETPC());
42     }
43 }
44 
45 void helper_boundl(CPUX86State *env, target_ulong a0, int v)
46 {
47     int low, high;
48 
49     low = cpu_ldl_data_ra(env, a0, GETPC());
50     high = cpu_ldl_data_ra(env, a0 + 4, GETPC());
51     if (v < low || v > high) {
52         if (env->hflags & HF_MPX_EN_MASK) {
53             env->bndcs_regs.sts = 0;
54         }
55         raise_exception_ra(env, EXCP05_BOUND, GETPC());
56     }
57 }
58