1fcf5ef2aSThomas Huth /*
2fcf5ef2aSThomas Huth * QEMU monitor
3fcf5ef2aSThomas Huth *
4fcf5ef2aSThomas Huth * Copyright (c) 2003-2004 Fabrice Bellard
5fcf5ef2aSThomas Huth *
6fcf5ef2aSThomas Huth * Permission is hereby granted, free of charge, to any person obtaining a copy
7fcf5ef2aSThomas Huth * of this software and associated documentation files (the "Software"), to deal
8fcf5ef2aSThomas Huth * in the Software without restriction, including without limitation the rights
9fcf5ef2aSThomas Huth * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10fcf5ef2aSThomas Huth * copies of the Software, and to permit persons to whom the Software is
11fcf5ef2aSThomas Huth * furnished to do so, subject to the following conditions:
12fcf5ef2aSThomas Huth *
13fcf5ef2aSThomas Huth * The above copyright notice and this permission notice shall be included in
14fcf5ef2aSThomas Huth * all copies or substantial portions of the Software.
15fcf5ef2aSThomas Huth *
16fcf5ef2aSThomas Huth * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17fcf5ef2aSThomas Huth * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18fcf5ef2aSThomas Huth * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19fcf5ef2aSThomas Huth * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20fcf5ef2aSThomas Huth * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21fcf5ef2aSThomas Huth * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22fcf5ef2aSThomas Huth * THE SOFTWARE.
23fcf5ef2aSThomas Huth */
24452fcdbcSMarkus Armbruster
25fcf5ef2aSThomas Huth #include "qemu/osdep.h"
26fcf5ef2aSThomas Huth #include "cpu.h"
27fcf5ef2aSThomas Huth #include "monitor/monitor.h"
28fcf5ef2aSThomas Huth #include "monitor/hmp-target.h"
29275307aaSMarkus Armbruster #include "monitor/hmp.h"
30452fcdbcSMarkus Armbruster #include "qapi/qmp/qdict.h"
3108a161fdSBrijesh Singh #include "qapi/error.h"
322ae16a6aSMarkus Armbruster #include "qapi/qapi-commands-misc-target.h"
3308a161fdSBrijesh Singh #include "qapi/qapi-commands-misc.h"
34fcf5ef2aSThomas Huth
353afc969aSDoug Gale /* Perform linear address sign extension */
addr_canonical(CPUArchState * env,hwaddr addr)363afc969aSDoug Gale static hwaddr addr_canonical(CPUArchState *env, hwaddr addr)
37fcf5ef2aSThomas Huth {
38fcf5ef2aSThomas Huth #ifdef TARGET_X86_64
396c7c3c21SKirill A. Shutemov if (env->cr[4] & CR4_LA57_MASK) {
406c7c3c21SKirill A. Shutemov if (addr & (1ULL << 56)) {
413afc969aSDoug Gale addr |= (hwaddr)-(1LL << 57);
426c7c3c21SKirill A. Shutemov }
436c7c3c21SKirill A. Shutemov } else {
44fcf5ef2aSThomas Huth if (addr & (1ULL << 47)) {
453afc969aSDoug Gale addr |= (hwaddr)-(1LL << 48);
46fcf5ef2aSThomas Huth }
476c7c3c21SKirill A. Shutemov }
48fcf5ef2aSThomas Huth #endif
493afc969aSDoug Gale return addr;
503afc969aSDoug Gale }
513afc969aSDoug Gale
print_pte(Monitor * mon,CPUArchState * env,hwaddr addr,hwaddr pte,hwaddr mask)523afc969aSDoug Gale static void print_pte(Monitor *mon, CPUArchState *env, hwaddr addr,
533afc969aSDoug Gale hwaddr pte, hwaddr mask)
543afc969aSDoug Gale {
553afc969aSDoug Gale addr = addr_canonical(env, addr);
563afc969aSDoug Gale
57*883f2c59SPhilippe Mathieu-Daudé monitor_printf(mon, HWADDR_FMT_plx ": " HWADDR_FMT_plx
58fcf5ef2aSThomas Huth " %c%c%c%c%c%c%c%c%c\n",
59fcf5ef2aSThomas Huth addr,
60fcf5ef2aSThomas Huth pte & mask,
61fcf5ef2aSThomas Huth pte & PG_NX_MASK ? 'X' : '-',
62fcf5ef2aSThomas Huth pte & PG_GLOBAL_MASK ? 'G' : '-',
63fcf5ef2aSThomas Huth pte & PG_PSE_MASK ? 'P' : '-',
64fcf5ef2aSThomas Huth pte & PG_DIRTY_MASK ? 'D' : '-',
65fcf5ef2aSThomas Huth pte & PG_ACCESSED_MASK ? 'A' : '-',
66fcf5ef2aSThomas Huth pte & PG_PCD_MASK ? 'C' : '-',
67fcf5ef2aSThomas Huth pte & PG_PWT_MASK ? 'T' : '-',
68fcf5ef2aSThomas Huth pte & PG_USER_MASK ? 'U' : '-',
69fcf5ef2aSThomas Huth pte & PG_RW_MASK ? 'W' : '-');
70fcf5ef2aSThomas Huth }
71fcf5ef2aSThomas Huth
tlb_info_32(Monitor * mon,CPUArchState * env)72fcf5ef2aSThomas Huth static void tlb_info_32(Monitor *mon, CPUArchState *env)
73fcf5ef2aSThomas Huth {
74fcf5ef2aSThomas Huth unsigned int l1, l2;
75fcf5ef2aSThomas Huth uint32_t pgd, pde, pte;
76fcf5ef2aSThomas Huth
77fcf5ef2aSThomas Huth pgd = env->cr[3] & ~0xfff;
78fcf5ef2aSThomas Huth for(l1 = 0; l1 < 1024; l1++) {
79fcf5ef2aSThomas Huth cpu_physical_memory_read(pgd + l1 * 4, &pde, 4);
80fcf5ef2aSThomas Huth pde = le32_to_cpu(pde);
81fcf5ef2aSThomas Huth if (pde & PG_PRESENT_MASK) {
82fcf5ef2aSThomas Huth if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
83fcf5ef2aSThomas Huth /* 4M pages */
846c7c3c21SKirill A. Shutemov print_pte(mon, env, (l1 << 22), pde, ~((1 << 21) - 1));
85fcf5ef2aSThomas Huth } else {
86fcf5ef2aSThomas Huth for(l2 = 0; l2 < 1024; l2++) {
87fcf5ef2aSThomas Huth cpu_physical_memory_read((pde & ~0xfff) + l2 * 4, &pte, 4);
88fcf5ef2aSThomas Huth pte = le32_to_cpu(pte);
89fcf5ef2aSThomas Huth if (pte & PG_PRESENT_MASK) {
906c7c3c21SKirill A. Shutemov print_pte(mon, env, (l1 << 22) + (l2 << 12),
91fcf5ef2aSThomas Huth pte & ~PG_PSE_MASK,
92fcf5ef2aSThomas Huth ~0xfff);
93fcf5ef2aSThomas Huth }
94fcf5ef2aSThomas Huth }
95fcf5ef2aSThomas Huth }
96fcf5ef2aSThomas Huth }
97fcf5ef2aSThomas Huth }
98fcf5ef2aSThomas Huth }
99fcf5ef2aSThomas Huth
tlb_info_pae32(Monitor * mon,CPUArchState * env)100fcf5ef2aSThomas Huth static void tlb_info_pae32(Monitor *mon, CPUArchState *env)
101fcf5ef2aSThomas Huth {
102fcf5ef2aSThomas Huth unsigned int l1, l2, l3;
103fcf5ef2aSThomas Huth uint64_t pdpe, pde, pte;
104fcf5ef2aSThomas Huth uint64_t pdp_addr, pd_addr, pt_addr;
105fcf5ef2aSThomas Huth
106fcf5ef2aSThomas Huth pdp_addr = env->cr[3] & ~0x1f;
107fcf5ef2aSThomas Huth for (l1 = 0; l1 < 4; l1++) {
108fcf5ef2aSThomas Huth cpu_physical_memory_read(pdp_addr + l1 * 8, &pdpe, 8);
109fcf5ef2aSThomas Huth pdpe = le64_to_cpu(pdpe);
110fcf5ef2aSThomas Huth if (pdpe & PG_PRESENT_MASK) {
111fcf5ef2aSThomas Huth pd_addr = pdpe & 0x3fffffffff000ULL;
112fcf5ef2aSThomas Huth for (l2 = 0; l2 < 512; l2++) {
113fcf5ef2aSThomas Huth cpu_physical_memory_read(pd_addr + l2 * 8, &pde, 8);
114fcf5ef2aSThomas Huth pde = le64_to_cpu(pde);
115fcf5ef2aSThomas Huth if (pde & PG_PRESENT_MASK) {
116fcf5ef2aSThomas Huth if (pde & PG_PSE_MASK) {
117fcf5ef2aSThomas Huth /* 2M pages with PAE, CR4.PSE is ignored */
1186c7c3c21SKirill A. Shutemov print_pte(mon, env, (l1 << 30) + (l2 << 21), pde,
119fcf5ef2aSThomas Huth ~((hwaddr)(1 << 20) - 1));
120fcf5ef2aSThomas Huth } else {
121fcf5ef2aSThomas Huth pt_addr = pde & 0x3fffffffff000ULL;
122fcf5ef2aSThomas Huth for (l3 = 0; l3 < 512; l3++) {
123fcf5ef2aSThomas Huth cpu_physical_memory_read(pt_addr + l3 * 8, &pte, 8);
124fcf5ef2aSThomas Huth pte = le64_to_cpu(pte);
125fcf5ef2aSThomas Huth if (pte & PG_PRESENT_MASK) {
1266c7c3c21SKirill A. Shutemov print_pte(mon, env, (l1 << 30) + (l2 << 21)
127fcf5ef2aSThomas Huth + (l3 << 12),
128fcf5ef2aSThomas Huth pte & ~PG_PSE_MASK,
129fcf5ef2aSThomas Huth ~(hwaddr)0xfff);
130fcf5ef2aSThomas Huth }
131fcf5ef2aSThomas Huth }
132fcf5ef2aSThomas Huth }
133fcf5ef2aSThomas Huth }
134fcf5ef2aSThomas Huth }
135fcf5ef2aSThomas Huth }
136fcf5ef2aSThomas Huth }
137fcf5ef2aSThomas Huth }
138fcf5ef2aSThomas Huth
139fcf5ef2aSThomas Huth #ifdef TARGET_X86_64
tlb_info_la48(Monitor * mon,CPUArchState * env,uint64_t l0,uint64_t pml4_addr)1406c7c3c21SKirill A. Shutemov static void tlb_info_la48(Monitor *mon, CPUArchState *env,
1416c7c3c21SKirill A. Shutemov uint64_t l0, uint64_t pml4_addr)
142fcf5ef2aSThomas Huth {
143fcf5ef2aSThomas Huth uint64_t l1, l2, l3, l4;
144fcf5ef2aSThomas Huth uint64_t pml4e, pdpe, pde, pte;
1456c7c3c21SKirill A. Shutemov uint64_t pdp_addr, pd_addr, pt_addr;
146fcf5ef2aSThomas Huth
147fcf5ef2aSThomas Huth for (l1 = 0; l1 < 512; l1++) {
148fcf5ef2aSThomas Huth cpu_physical_memory_read(pml4_addr + l1 * 8, &pml4e, 8);
149fcf5ef2aSThomas Huth pml4e = le64_to_cpu(pml4e);
1506c7c3c21SKirill A. Shutemov if (!(pml4e & PG_PRESENT_MASK)) {
1516c7c3c21SKirill A. Shutemov continue;
1526c7c3c21SKirill A. Shutemov }
1536c7c3c21SKirill A. Shutemov
154fcf5ef2aSThomas Huth pdp_addr = pml4e & 0x3fffffffff000ULL;
155fcf5ef2aSThomas Huth for (l2 = 0; l2 < 512; l2++) {
156fcf5ef2aSThomas Huth cpu_physical_memory_read(pdp_addr + l2 * 8, &pdpe, 8);
157fcf5ef2aSThomas Huth pdpe = le64_to_cpu(pdpe);
1586c7c3c21SKirill A. Shutemov if (!(pdpe & PG_PRESENT_MASK)) {
1596c7c3c21SKirill A. Shutemov continue;
1606c7c3c21SKirill A. Shutemov }
1616c7c3c21SKirill A. Shutemov
162fcf5ef2aSThomas Huth if (pdpe & PG_PSE_MASK) {
163fcf5ef2aSThomas Huth /* 1G pages, CR4.PSE is ignored */
1646c7c3c21SKirill A. Shutemov print_pte(mon, env, (l0 << 48) + (l1 << 39) + (l2 << 30),
1656c7c3c21SKirill A. Shutemov pdpe, 0x3ffffc0000000ULL);
1666c7c3c21SKirill A. Shutemov continue;
1676c7c3c21SKirill A. Shutemov }
1686c7c3c21SKirill A. Shutemov
169fcf5ef2aSThomas Huth pd_addr = pdpe & 0x3fffffffff000ULL;
170fcf5ef2aSThomas Huth for (l3 = 0; l3 < 512; l3++) {
171fcf5ef2aSThomas Huth cpu_physical_memory_read(pd_addr + l3 * 8, &pde, 8);
172fcf5ef2aSThomas Huth pde = le64_to_cpu(pde);
1736c7c3c21SKirill A. Shutemov if (!(pde & PG_PRESENT_MASK)) {
1746c7c3c21SKirill A. Shutemov continue;
1756c7c3c21SKirill A. Shutemov }
1766c7c3c21SKirill A. Shutemov
177fcf5ef2aSThomas Huth if (pde & PG_PSE_MASK) {
178fcf5ef2aSThomas Huth /* 2M pages, CR4.PSE is ignored */
1796c7c3c21SKirill A. Shutemov print_pte(mon, env, (l0 << 48) + (l1 << 39) + (l2 << 30) +
1806c7c3c21SKirill A. Shutemov (l3 << 21), pde, 0x3ffffffe00000ULL);
1816c7c3c21SKirill A. Shutemov continue;
1826c7c3c21SKirill A. Shutemov }
1836c7c3c21SKirill A. Shutemov
184fcf5ef2aSThomas Huth pt_addr = pde & 0x3fffffffff000ULL;
185fcf5ef2aSThomas Huth for (l4 = 0; l4 < 512; l4++) {
186fcf5ef2aSThomas Huth cpu_physical_memory_read(pt_addr
187fcf5ef2aSThomas Huth + l4 * 8,
188fcf5ef2aSThomas Huth &pte, 8);
189fcf5ef2aSThomas Huth pte = le64_to_cpu(pte);
190fcf5ef2aSThomas Huth if (pte & PG_PRESENT_MASK) {
1916c7c3c21SKirill A. Shutemov print_pte(mon, env, (l0 << 48) + (l1 << 39) +
1926c7c3c21SKirill A. Shutemov (l2 << 30) + (l3 << 21) + (l4 << 12),
1936c7c3c21SKirill A. Shutemov pte & ~PG_PSE_MASK, 0x3fffffffff000ULL);
194fcf5ef2aSThomas Huth }
195fcf5ef2aSThomas Huth }
196fcf5ef2aSThomas Huth }
197fcf5ef2aSThomas Huth }
198fcf5ef2aSThomas Huth }
199fcf5ef2aSThomas Huth }
2006c7c3c21SKirill A. Shutemov
tlb_info_la57(Monitor * mon,CPUArchState * env)2016c7c3c21SKirill A. Shutemov static void tlb_info_la57(Monitor *mon, CPUArchState *env)
2026c7c3c21SKirill A. Shutemov {
2036c7c3c21SKirill A. Shutemov uint64_t l0;
2046c7c3c21SKirill A. Shutemov uint64_t pml5e;
2056c7c3c21SKirill A. Shutemov uint64_t pml5_addr;
2066c7c3c21SKirill A. Shutemov
2076c7c3c21SKirill A. Shutemov pml5_addr = env->cr[3] & 0x3fffffffff000ULL;
2086c7c3c21SKirill A. Shutemov for (l0 = 0; l0 < 512; l0++) {
2096c7c3c21SKirill A. Shutemov cpu_physical_memory_read(pml5_addr + l0 * 8, &pml5e, 8);
2106c7c3c21SKirill A. Shutemov pml5e = le64_to_cpu(pml5e);
2116c7c3c21SKirill A. Shutemov if (pml5e & PG_PRESENT_MASK) {
2126c7c3c21SKirill A. Shutemov tlb_info_la48(mon, env, l0, pml5e & 0x3fffffffff000ULL);
213fcf5ef2aSThomas Huth }
214fcf5ef2aSThomas Huth }
215fcf5ef2aSThomas Huth }
216fcf5ef2aSThomas Huth #endif /* TARGET_X86_64 */
217fcf5ef2aSThomas Huth
hmp_info_tlb(Monitor * mon,const QDict * qdict)218fcf5ef2aSThomas Huth void hmp_info_tlb(Monitor *mon, const QDict *qdict)
219fcf5ef2aSThomas Huth {
220fcf5ef2aSThomas Huth CPUArchState *env;
221fcf5ef2aSThomas Huth
222e7cff9c6SKevin Wolf env = mon_get_cpu_env(mon);
223854e67feSThomas Huth if (!env) {
224854e67feSThomas Huth monitor_printf(mon, "No CPU available\n");
225854e67feSThomas Huth return;
226854e67feSThomas Huth }
227fcf5ef2aSThomas Huth
228fcf5ef2aSThomas Huth if (!(env->cr[0] & CR0_PG_MASK)) {
229fcf5ef2aSThomas Huth monitor_printf(mon, "PG disabled\n");
230fcf5ef2aSThomas Huth return;
231fcf5ef2aSThomas Huth }
232fcf5ef2aSThomas Huth if (env->cr[4] & CR4_PAE_MASK) {
233fcf5ef2aSThomas Huth #ifdef TARGET_X86_64
234fcf5ef2aSThomas Huth if (env->hflags & HF_LMA_MASK) {
2356c7c3c21SKirill A. Shutemov if (env->cr[4] & CR4_LA57_MASK) {
2366c7c3c21SKirill A. Shutemov tlb_info_la57(mon, env);
2376c7c3c21SKirill A. Shutemov } else {
2386c7c3c21SKirill A. Shutemov tlb_info_la48(mon, env, 0, env->cr[3] & 0x3fffffffff000ULL);
2396c7c3c21SKirill A. Shutemov }
240fcf5ef2aSThomas Huth } else
241fcf5ef2aSThomas Huth #endif
242fcf5ef2aSThomas Huth {
243fcf5ef2aSThomas Huth tlb_info_pae32(mon, env);
244fcf5ef2aSThomas Huth }
245fcf5ef2aSThomas Huth } else {
246fcf5ef2aSThomas Huth tlb_info_32(mon, env);
247fcf5ef2aSThomas Huth }
248fcf5ef2aSThomas Huth }
249fcf5ef2aSThomas Huth
mem_print(Monitor * mon,CPUArchState * env,hwaddr * pstart,int * plast_prot,hwaddr end,int prot)2503afc969aSDoug Gale static void mem_print(Monitor *mon, CPUArchState *env,
2513afc969aSDoug Gale hwaddr *pstart, int *plast_prot,
252fcf5ef2aSThomas Huth hwaddr end, int prot)
253fcf5ef2aSThomas Huth {
254fcf5ef2aSThomas Huth int prot1;
255fcf5ef2aSThomas Huth prot1 = *plast_prot;
256fcf5ef2aSThomas Huth if (prot != prot1) {
257fcf5ef2aSThomas Huth if (*pstart != -1) {
258*883f2c59SPhilippe Mathieu-Daudé monitor_printf(mon, HWADDR_FMT_plx "-" HWADDR_FMT_plx " "
259*883f2c59SPhilippe Mathieu-Daudé HWADDR_FMT_plx " %c%c%c\n",
2603afc969aSDoug Gale addr_canonical(env, *pstart),
2613afc969aSDoug Gale addr_canonical(env, end),
2623afc969aSDoug Gale addr_canonical(env, end - *pstart),
263fcf5ef2aSThomas Huth prot1 & PG_USER_MASK ? 'u' : '-',
264fcf5ef2aSThomas Huth 'r',
265fcf5ef2aSThomas Huth prot1 & PG_RW_MASK ? 'w' : '-');
266fcf5ef2aSThomas Huth }
267fcf5ef2aSThomas Huth if (prot != 0)
268fcf5ef2aSThomas Huth *pstart = end;
269fcf5ef2aSThomas Huth else
270fcf5ef2aSThomas Huth *pstart = -1;
271fcf5ef2aSThomas Huth *plast_prot = prot;
272fcf5ef2aSThomas Huth }
273fcf5ef2aSThomas Huth }
274fcf5ef2aSThomas Huth
mem_info_32(Monitor * mon,CPUArchState * env)275fcf5ef2aSThomas Huth static void mem_info_32(Monitor *mon, CPUArchState *env)
276fcf5ef2aSThomas Huth {
277fcf5ef2aSThomas Huth unsigned int l1, l2;
278fcf5ef2aSThomas Huth int prot, last_prot;
279fcf5ef2aSThomas Huth uint32_t pgd, pde, pte;
280fcf5ef2aSThomas Huth hwaddr start, end;
281fcf5ef2aSThomas Huth
282fcf5ef2aSThomas Huth pgd = env->cr[3] & ~0xfff;
283fcf5ef2aSThomas Huth last_prot = 0;
284fcf5ef2aSThomas Huth start = -1;
285fcf5ef2aSThomas Huth for(l1 = 0; l1 < 1024; l1++) {
286fcf5ef2aSThomas Huth cpu_physical_memory_read(pgd + l1 * 4, &pde, 4);
287fcf5ef2aSThomas Huth pde = le32_to_cpu(pde);
288fcf5ef2aSThomas Huth end = l1 << 22;
289fcf5ef2aSThomas Huth if (pde & PG_PRESENT_MASK) {
290fcf5ef2aSThomas Huth if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
291fcf5ef2aSThomas Huth prot = pde & (PG_USER_MASK | PG_RW_MASK | PG_PRESENT_MASK);
2923afc969aSDoug Gale mem_print(mon, env, &start, &last_prot, end, prot);
293fcf5ef2aSThomas Huth } else {
294fcf5ef2aSThomas Huth for(l2 = 0; l2 < 1024; l2++) {
295fcf5ef2aSThomas Huth cpu_physical_memory_read((pde & ~0xfff) + l2 * 4, &pte, 4);
296fcf5ef2aSThomas Huth pte = le32_to_cpu(pte);
297fcf5ef2aSThomas Huth end = (l1 << 22) + (l2 << 12);
298fcf5ef2aSThomas Huth if (pte & PG_PRESENT_MASK) {
299fcf5ef2aSThomas Huth prot = pte & pde &
300fcf5ef2aSThomas Huth (PG_USER_MASK | PG_RW_MASK | PG_PRESENT_MASK);
301fcf5ef2aSThomas Huth } else {
302fcf5ef2aSThomas Huth prot = 0;
303fcf5ef2aSThomas Huth }
3043afc969aSDoug Gale mem_print(mon, env, &start, &last_prot, end, prot);
305fcf5ef2aSThomas Huth }
306fcf5ef2aSThomas Huth }
307fcf5ef2aSThomas Huth } else {
308fcf5ef2aSThomas Huth prot = 0;
3093afc969aSDoug Gale mem_print(mon, env, &start, &last_prot, end, prot);
310fcf5ef2aSThomas Huth }
311fcf5ef2aSThomas Huth }
312fcf5ef2aSThomas Huth /* Flush last range */
3133afc969aSDoug Gale mem_print(mon, env, &start, &last_prot, (hwaddr)1 << 32, 0);
314fcf5ef2aSThomas Huth }
315fcf5ef2aSThomas Huth
mem_info_pae32(Monitor * mon,CPUArchState * env)316fcf5ef2aSThomas Huth static void mem_info_pae32(Monitor *mon, CPUArchState *env)
317fcf5ef2aSThomas Huth {
318fcf5ef2aSThomas Huth unsigned int l1, l2, l3;
319fcf5ef2aSThomas Huth int prot, last_prot;
320fcf5ef2aSThomas Huth uint64_t pdpe, pde, pte;
321fcf5ef2aSThomas Huth uint64_t pdp_addr, pd_addr, pt_addr;
322fcf5ef2aSThomas Huth hwaddr start, end;
323fcf5ef2aSThomas Huth
324fcf5ef2aSThomas Huth pdp_addr = env->cr[3] & ~0x1f;
325fcf5ef2aSThomas Huth last_prot = 0;
326fcf5ef2aSThomas Huth start = -1;
327fcf5ef2aSThomas Huth for (l1 = 0; l1 < 4; l1++) {
328fcf5ef2aSThomas Huth cpu_physical_memory_read(pdp_addr + l1 * 8, &pdpe, 8);
329fcf5ef2aSThomas Huth pdpe = le64_to_cpu(pdpe);
330fcf5ef2aSThomas Huth end = l1 << 30;
331fcf5ef2aSThomas Huth if (pdpe & PG_PRESENT_MASK) {
332fcf5ef2aSThomas Huth pd_addr = pdpe & 0x3fffffffff000ULL;
333fcf5ef2aSThomas Huth for (l2 = 0; l2 < 512; l2++) {
334fcf5ef2aSThomas Huth cpu_physical_memory_read(pd_addr + l2 * 8, &pde, 8);
335fcf5ef2aSThomas Huth pde = le64_to_cpu(pde);
336fcf5ef2aSThomas Huth end = (l1 << 30) + (l2 << 21);
337fcf5ef2aSThomas Huth if (pde & PG_PRESENT_MASK) {
338fcf5ef2aSThomas Huth if (pde & PG_PSE_MASK) {
339fcf5ef2aSThomas Huth prot = pde & (PG_USER_MASK | PG_RW_MASK |
340fcf5ef2aSThomas Huth PG_PRESENT_MASK);
3413afc969aSDoug Gale mem_print(mon, env, &start, &last_prot, end, prot);
342fcf5ef2aSThomas Huth } else {
343fcf5ef2aSThomas Huth pt_addr = pde & 0x3fffffffff000ULL;
344fcf5ef2aSThomas Huth for (l3 = 0; l3 < 512; l3++) {
345fcf5ef2aSThomas Huth cpu_physical_memory_read(pt_addr + l3 * 8, &pte, 8);
346fcf5ef2aSThomas Huth pte = le64_to_cpu(pte);
347fcf5ef2aSThomas Huth end = (l1 << 30) + (l2 << 21) + (l3 << 12);
348fcf5ef2aSThomas Huth if (pte & PG_PRESENT_MASK) {
349fcf5ef2aSThomas Huth prot = pte & pde & (PG_USER_MASK | PG_RW_MASK |
350fcf5ef2aSThomas Huth PG_PRESENT_MASK);
351fcf5ef2aSThomas Huth } else {
352fcf5ef2aSThomas Huth prot = 0;
353fcf5ef2aSThomas Huth }
3543afc969aSDoug Gale mem_print(mon, env, &start, &last_prot, end, prot);
355fcf5ef2aSThomas Huth }
356fcf5ef2aSThomas Huth }
357fcf5ef2aSThomas Huth } else {
358fcf5ef2aSThomas Huth prot = 0;
3593afc969aSDoug Gale mem_print(mon, env, &start, &last_prot, end, prot);
360fcf5ef2aSThomas Huth }
361fcf5ef2aSThomas Huth }
362fcf5ef2aSThomas Huth } else {
363fcf5ef2aSThomas Huth prot = 0;
3643afc969aSDoug Gale mem_print(mon, env, &start, &last_prot, end, prot);
365fcf5ef2aSThomas Huth }
366fcf5ef2aSThomas Huth }
367fcf5ef2aSThomas Huth /* Flush last range */
3683afc969aSDoug Gale mem_print(mon, env, &start, &last_prot, (hwaddr)1 << 32, 0);
369fcf5ef2aSThomas Huth }
370fcf5ef2aSThomas Huth
371fcf5ef2aSThomas Huth
372fcf5ef2aSThomas Huth #ifdef TARGET_X86_64
mem_info_la48(Monitor * mon,CPUArchState * env)3736c7c3c21SKirill A. Shutemov static void mem_info_la48(Monitor *mon, CPUArchState *env)
374fcf5ef2aSThomas Huth {
375fcf5ef2aSThomas Huth int prot, last_prot;
376fcf5ef2aSThomas Huth uint64_t l1, l2, l3, l4;
377fcf5ef2aSThomas Huth uint64_t pml4e, pdpe, pde, pte;
378fcf5ef2aSThomas Huth uint64_t pml4_addr, pdp_addr, pd_addr, pt_addr, start, end;
379fcf5ef2aSThomas Huth
380fcf5ef2aSThomas Huth pml4_addr = env->cr[3] & 0x3fffffffff000ULL;
381fcf5ef2aSThomas Huth last_prot = 0;
382fcf5ef2aSThomas Huth start = -1;
383fcf5ef2aSThomas Huth for (l1 = 0; l1 < 512; l1++) {
384fcf5ef2aSThomas Huth cpu_physical_memory_read(pml4_addr + l1 * 8, &pml4e, 8);
385fcf5ef2aSThomas Huth pml4e = le64_to_cpu(pml4e);
386fcf5ef2aSThomas Huth end = l1 << 39;
387fcf5ef2aSThomas Huth if (pml4e & PG_PRESENT_MASK) {
388fcf5ef2aSThomas Huth pdp_addr = pml4e & 0x3fffffffff000ULL;
389fcf5ef2aSThomas Huth for (l2 = 0; l2 < 512; l2++) {
390fcf5ef2aSThomas Huth cpu_physical_memory_read(pdp_addr + l2 * 8, &pdpe, 8);
391fcf5ef2aSThomas Huth pdpe = le64_to_cpu(pdpe);
392fcf5ef2aSThomas Huth end = (l1 << 39) + (l2 << 30);
393fcf5ef2aSThomas Huth if (pdpe & PG_PRESENT_MASK) {
394fcf5ef2aSThomas Huth if (pdpe & PG_PSE_MASK) {
395fcf5ef2aSThomas Huth prot = pdpe & (PG_USER_MASK | PG_RW_MASK |
396fcf5ef2aSThomas Huth PG_PRESENT_MASK);
397fcf5ef2aSThomas Huth prot &= pml4e;
3983afc969aSDoug Gale mem_print(mon, env, &start, &last_prot, end, prot);
399fcf5ef2aSThomas Huth } else {
400fcf5ef2aSThomas Huth pd_addr = pdpe & 0x3fffffffff000ULL;
401fcf5ef2aSThomas Huth for (l3 = 0; l3 < 512; l3++) {
402fcf5ef2aSThomas Huth cpu_physical_memory_read(pd_addr + l3 * 8, &pde, 8);
403fcf5ef2aSThomas Huth pde = le64_to_cpu(pde);
404fcf5ef2aSThomas Huth end = (l1 << 39) + (l2 << 30) + (l3 << 21);
405fcf5ef2aSThomas Huth if (pde & PG_PRESENT_MASK) {
406fcf5ef2aSThomas Huth if (pde & PG_PSE_MASK) {
407fcf5ef2aSThomas Huth prot = pde & (PG_USER_MASK | PG_RW_MASK |
408fcf5ef2aSThomas Huth PG_PRESENT_MASK);
409fcf5ef2aSThomas Huth prot &= pml4e & pdpe;
4103afc969aSDoug Gale mem_print(mon, env, &start,
4113afc969aSDoug Gale &last_prot, end, prot);
412fcf5ef2aSThomas Huth } else {
413fcf5ef2aSThomas Huth pt_addr = pde & 0x3fffffffff000ULL;
414fcf5ef2aSThomas Huth for (l4 = 0; l4 < 512; l4++) {
415fcf5ef2aSThomas Huth cpu_physical_memory_read(pt_addr
416fcf5ef2aSThomas Huth + l4 * 8,
417fcf5ef2aSThomas Huth &pte, 8);
418fcf5ef2aSThomas Huth pte = le64_to_cpu(pte);
419fcf5ef2aSThomas Huth end = (l1 << 39) + (l2 << 30) +
420fcf5ef2aSThomas Huth (l3 << 21) + (l4 << 12);
421fcf5ef2aSThomas Huth if (pte & PG_PRESENT_MASK) {
422fcf5ef2aSThomas Huth prot = pte & (PG_USER_MASK | PG_RW_MASK |
423fcf5ef2aSThomas Huth PG_PRESENT_MASK);
424fcf5ef2aSThomas Huth prot &= pml4e & pdpe & pde;
425fcf5ef2aSThomas Huth } else {
426fcf5ef2aSThomas Huth prot = 0;
427fcf5ef2aSThomas Huth }
4283afc969aSDoug Gale mem_print(mon, env, &start,
4293afc969aSDoug Gale &last_prot, end, prot);
430fcf5ef2aSThomas Huth }
431fcf5ef2aSThomas Huth }
432fcf5ef2aSThomas Huth } else {
433fcf5ef2aSThomas Huth prot = 0;
4343afc969aSDoug Gale mem_print(mon, env, &start,
4353afc969aSDoug Gale &last_prot, end, prot);
436fcf5ef2aSThomas Huth }
437fcf5ef2aSThomas Huth }
438fcf5ef2aSThomas Huth }
439fcf5ef2aSThomas Huth } else {
440fcf5ef2aSThomas Huth prot = 0;
4413afc969aSDoug Gale mem_print(mon, env, &start, &last_prot, end, prot);
442fcf5ef2aSThomas Huth }
443fcf5ef2aSThomas Huth }
444fcf5ef2aSThomas Huth } else {
445fcf5ef2aSThomas Huth prot = 0;
4463afc969aSDoug Gale mem_print(mon, env, &start, &last_prot, end, prot);
447fcf5ef2aSThomas Huth }
448fcf5ef2aSThomas Huth }
449fcf5ef2aSThomas Huth /* Flush last range */
4503afc969aSDoug Gale mem_print(mon, env, &start, &last_prot, (hwaddr)1 << 48, 0);
451fcf5ef2aSThomas Huth }
4526c7c3c21SKirill A. Shutemov
mem_info_la57(Monitor * mon,CPUArchState * env)4536c7c3c21SKirill A. Shutemov static void mem_info_la57(Monitor *mon, CPUArchState *env)
4546c7c3c21SKirill A. Shutemov {
4556c7c3c21SKirill A. Shutemov int prot, last_prot;
4566c7c3c21SKirill A. Shutemov uint64_t l0, l1, l2, l3, l4;
4576c7c3c21SKirill A. Shutemov uint64_t pml5e, pml4e, pdpe, pde, pte;
4586c7c3c21SKirill A. Shutemov uint64_t pml5_addr, pml4_addr, pdp_addr, pd_addr, pt_addr, start, end;
4596c7c3c21SKirill A. Shutemov
4606c7c3c21SKirill A. Shutemov pml5_addr = env->cr[3] & 0x3fffffffff000ULL;
4616c7c3c21SKirill A. Shutemov last_prot = 0;
4626c7c3c21SKirill A. Shutemov start = -1;
4636c7c3c21SKirill A. Shutemov for (l0 = 0; l0 < 512; l0++) {
4646c7c3c21SKirill A. Shutemov cpu_physical_memory_read(pml5_addr + l0 * 8, &pml5e, 8);
465128b52e8SPaolo Bonzini pml5e = le64_to_cpu(pml5e);
4666c7c3c21SKirill A. Shutemov end = l0 << 48;
4676c7c3c21SKirill A. Shutemov if (!(pml5e & PG_PRESENT_MASK)) {
4686c7c3c21SKirill A. Shutemov prot = 0;
4693afc969aSDoug Gale mem_print(mon, env, &start, &last_prot, end, prot);
4706c7c3c21SKirill A. Shutemov continue;
4716c7c3c21SKirill A. Shutemov }
4726c7c3c21SKirill A. Shutemov
4736c7c3c21SKirill A. Shutemov pml4_addr = pml5e & 0x3fffffffff000ULL;
4746c7c3c21SKirill A. Shutemov for (l1 = 0; l1 < 512; l1++) {
4756c7c3c21SKirill A. Shutemov cpu_physical_memory_read(pml4_addr + l1 * 8, &pml4e, 8);
4766c7c3c21SKirill A. Shutemov pml4e = le64_to_cpu(pml4e);
4776c7c3c21SKirill A. Shutemov end = (l0 << 48) + (l1 << 39);
4786c7c3c21SKirill A. Shutemov if (!(pml4e & PG_PRESENT_MASK)) {
4796c7c3c21SKirill A. Shutemov prot = 0;
4803afc969aSDoug Gale mem_print(mon, env, &start, &last_prot, end, prot);
4816c7c3c21SKirill A. Shutemov continue;
4826c7c3c21SKirill A. Shutemov }
4836c7c3c21SKirill A. Shutemov
4846c7c3c21SKirill A. Shutemov pdp_addr = pml4e & 0x3fffffffff000ULL;
4856c7c3c21SKirill A. Shutemov for (l2 = 0; l2 < 512; l2++) {
4866c7c3c21SKirill A. Shutemov cpu_physical_memory_read(pdp_addr + l2 * 8, &pdpe, 8);
4876c7c3c21SKirill A. Shutemov pdpe = le64_to_cpu(pdpe);
4886c7c3c21SKirill A. Shutemov end = (l0 << 48) + (l1 << 39) + (l2 << 30);
4896c7c3c21SKirill A. Shutemov if (pdpe & PG_PRESENT_MASK) {
4906c7c3c21SKirill A. Shutemov prot = 0;
4913afc969aSDoug Gale mem_print(mon, env, &start, &last_prot, end, prot);
4926c7c3c21SKirill A. Shutemov continue;
4936c7c3c21SKirill A. Shutemov }
4946c7c3c21SKirill A. Shutemov
4956c7c3c21SKirill A. Shutemov if (pdpe & PG_PSE_MASK) {
4966c7c3c21SKirill A. Shutemov prot = pdpe & (PG_USER_MASK | PG_RW_MASK |
4976c7c3c21SKirill A. Shutemov PG_PRESENT_MASK);
498128b52e8SPaolo Bonzini prot &= pml5e & pml4e;
4993afc969aSDoug Gale mem_print(mon, env, &start, &last_prot, end, prot);
5006c7c3c21SKirill A. Shutemov continue;
5016c7c3c21SKirill A. Shutemov }
5026c7c3c21SKirill A. Shutemov
5036c7c3c21SKirill A. Shutemov pd_addr = pdpe & 0x3fffffffff000ULL;
5046c7c3c21SKirill A. Shutemov for (l3 = 0; l3 < 512; l3++) {
5056c7c3c21SKirill A. Shutemov cpu_physical_memory_read(pd_addr + l3 * 8, &pde, 8);
5066c7c3c21SKirill A. Shutemov pde = le64_to_cpu(pde);
5076c7c3c21SKirill A. Shutemov end = (l0 << 48) + (l1 << 39) + (l2 << 30) + (l3 << 21);
5086c7c3c21SKirill A. Shutemov if (pde & PG_PRESENT_MASK) {
5096c7c3c21SKirill A. Shutemov prot = 0;
5103afc969aSDoug Gale mem_print(mon, env, &start, &last_prot, end, prot);
5116c7c3c21SKirill A. Shutemov continue;
5126c7c3c21SKirill A. Shutemov }
5136c7c3c21SKirill A. Shutemov
5146c7c3c21SKirill A. Shutemov if (pde & PG_PSE_MASK) {
5156c7c3c21SKirill A. Shutemov prot = pde & (PG_USER_MASK | PG_RW_MASK |
5166c7c3c21SKirill A. Shutemov PG_PRESENT_MASK);
517128b52e8SPaolo Bonzini prot &= pml5e & pml4e & pdpe;
5183afc969aSDoug Gale mem_print(mon, env, &start, &last_prot, end, prot);
5196c7c3c21SKirill A. Shutemov continue;
5206c7c3c21SKirill A. Shutemov }
5216c7c3c21SKirill A. Shutemov
5226c7c3c21SKirill A. Shutemov pt_addr = pde & 0x3fffffffff000ULL;
5236c7c3c21SKirill A. Shutemov for (l4 = 0; l4 < 512; l4++) {
5246c7c3c21SKirill A. Shutemov cpu_physical_memory_read(pt_addr + l4 * 8, &pte, 8);
5256c7c3c21SKirill A. Shutemov pte = le64_to_cpu(pte);
5266c7c3c21SKirill A. Shutemov end = (l0 << 48) + (l1 << 39) + (l2 << 30) +
5276c7c3c21SKirill A. Shutemov (l3 << 21) + (l4 << 12);
5286c7c3c21SKirill A. Shutemov if (pte & PG_PRESENT_MASK) {
5296c7c3c21SKirill A. Shutemov prot = pte & (PG_USER_MASK | PG_RW_MASK |
5306c7c3c21SKirill A. Shutemov PG_PRESENT_MASK);
531128b52e8SPaolo Bonzini prot &= pml5e & pml4e & pdpe & pde;
5326c7c3c21SKirill A. Shutemov } else {
5336c7c3c21SKirill A. Shutemov prot = 0;
5346c7c3c21SKirill A. Shutemov }
5353afc969aSDoug Gale mem_print(mon, env, &start, &last_prot, end, prot);
5366c7c3c21SKirill A. Shutemov }
5376c7c3c21SKirill A. Shutemov }
5386c7c3c21SKirill A. Shutemov }
5396c7c3c21SKirill A. Shutemov }
5406c7c3c21SKirill A. Shutemov }
5416c7c3c21SKirill A. Shutemov /* Flush last range */
5423afc969aSDoug Gale mem_print(mon, env, &start, &last_prot, (hwaddr)1 << 57, 0);
5436c7c3c21SKirill A. Shutemov }
544fcf5ef2aSThomas Huth #endif /* TARGET_X86_64 */
545fcf5ef2aSThomas Huth
hmp_info_mem(Monitor * mon,const QDict * qdict)546fcf5ef2aSThomas Huth void hmp_info_mem(Monitor *mon, const QDict *qdict)
547fcf5ef2aSThomas Huth {
548fcf5ef2aSThomas Huth CPUArchState *env;
549fcf5ef2aSThomas Huth
550e7cff9c6SKevin Wolf env = mon_get_cpu_env(mon);
551854e67feSThomas Huth if (!env) {
552854e67feSThomas Huth monitor_printf(mon, "No CPU available\n");
553854e67feSThomas Huth return;
554854e67feSThomas Huth }
555fcf5ef2aSThomas Huth
556fcf5ef2aSThomas Huth if (!(env->cr[0] & CR0_PG_MASK)) {
557fcf5ef2aSThomas Huth monitor_printf(mon, "PG disabled\n");
558fcf5ef2aSThomas Huth return;
559fcf5ef2aSThomas Huth }
560fcf5ef2aSThomas Huth if (env->cr[4] & CR4_PAE_MASK) {
561fcf5ef2aSThomas Huth #ifdef TARGET_X86_64
562fcf5ef2aSThomas Huth if (env->hflags & HF_LMA_MASK) {
5636c7c3c21SKirill A. Shutemov if (env->cr[4] & CR4_LA57_MASK) {
5646c7c3c21SKirill A. Shutemov mem_info_la57(mon, env);
5656c7c3c21SKirill A. Shutemov } else {
5666c7c3c21SKirill A. Shutemov mem_info_la48(mon, env);
5676c7c3c21SKirill A. Shutemov }
568fcf5ef2aSThomas Huth } else
569fcf5ef2aSThomas Huth #endif
570fcf5ef2aSThomas Huth {
571fcf5ef2aSThomas Huth mem_info_pae32(mon, env);
572fcf5ef2aSThomas Huth }
573fcf5ef2aSThomas Huth } else {
574fcf5ef2aSThomas Huth mem_info_32(mon, env);
575fcf5ef2aSThomas Huth }
576fcf5ef2aSThomas Huth }
577fcf5ef2aSThomas Huth
hmp_mce(Monitor * mon,const QDict * qdict)578fcf5ef2aSThomas Huth void hmp_mce(Monitor *mon, const QDict *qdict)
579fcf5ef2aSThomas Huth {
580fcf5ef2aSThomas Huth X86CPU *cpu;
581fcf5ef2aSThomas Huth CPUState *cs;
582fcf5ef2aSThomas Huth int cpu_index = qdict_get_int(qdict, "cpu_index");
583fcf5ef2aSThomas Huth int bank = qdict_get_int(qdict, "bank");
584fcf5ef2aSThomas Huth uint64_t status = qdict_get_int(qdict, "status");
585fcf5ef2aSThomas Huth uint64_t mcg_status = qdict_get_int(qdict, "mcg_status");
586fcf5ef2aSThomas Huth uint64_t addr = qdict_get_int(qdict, "addr");
587fcf5ef2aSThomas Huth uint64_t misc = qdict_get_int(qdict, "misc");
588fcf5ef2aSThomas Huth int flags = MCE_INJECT_UNCOND_AO;
589fcf5ef2aSThomas Huth
590fcf5ef2aSThomas Huth if (qdict_get_try_bool(qdict, "broadcast", false)) {
591fcf5ef2aSThomas Huth flags |= MCE_INJECT_BROADCAST;
592fcf5ef2aSThomas Huth }
593fcf5ef2aSThomas Huth cs = qemu_get_cpu(cpu_index);
594fcf5ef2aSThomas Huth if (cs != NULL) {
595fcf5ef2aSThomas Huth cpu = X86_CPU(cs);
596fcf5ef2aSThomas Huth cpu_x86_inject_mce(mon, cpu, bank, status, mcg_status, addr, misc,
597fcf5ef2aSThomas Huth flags);
598fcf5ef2aSThomas Huth }
599fcf5ef2aSThomas Huth }
600fcf5ef2aSThomas Huth
monitor_get_pc(Monitor * mon,const struct MonitorDef * md,int val)60143cf067fSKevin Wolf static target_long monitor_get_pc(Monitor *mon, const struct MonitorDef *md,
60243cf067fSKevin Wolf int val)
603fcf5ef2aSThomas Huth {
604e7cff9c6SKevin Wolf CPUArchState *env = mon_get_cpu_env(mon);
605fcf5ef2aSThomas Huth return env->eip + env->segs[R_CS].base;
606fcf5ef2aSThomas Huth }
607fcf5ef2aSThomas Huth
608fcf5ef2aSThomas Huth const MonitorDef monitor_defs[] = {
609fcf5ef2aSThomas Huth #define SEG(name, seg) \
610fcf5ef2aSThomas Huth { name, offsetof(CPUX86State, segs[seg].selector), NULL, MD_I32 },\
611fcf5ef2aSThomas Huth { name ".base", offsetof(CPUX86State, segs[seg].base) },\
612fcf5ef2aSThomas Huth { name ".limit", offsetof(CPUX86State, segs[seg].limit), NULL, MD_I32 },
613fcf5ef2aSThomas Huth
614fcf5ef2aSThomas Huth { "eax", offsetof(CPUX86State, regs[0]) },
615fcf5ef2aSThomas Huth { "ecx", offsetof(CPUX86State, regs[1]) },
616fcf5ef2aSThomas Huth { "edx", offsetof(CPUX86State, regs[2]) },
617fcf5ef2aSThomas Huth { "ebx", offsetof(CPUX86State, regs[3]) },
618fcf5ef2aSThomas Huth { "esp|sp", offsetof(CPUX86State, regs[4]) },
619fcf5ef2aSThomas Huth { "ebp|fp", offsetof(CPUX86State, regs[5]) },
620fcf5ef2aSThomas Huth { "esi", offsetof(CPUX86State, regs[6]) },
621fcf5ef2aSThomas Huth { "edi", offsetof(CPUX86State, regs[7]) },
622fcf5ef2aSThomas Huth #ifdef TARGET_X86_64
623fcf5ef2aSThomas Huth { "r8", offsetof(CPUX86State, regs[8]) },
624fcf5ef2aSThomas Huth { "r9", offsetof(CPUX86State, regs[9]) },
625fcf5ef2aSThomas Huth { "r10", offsetof(CPUX86State, regs[10]) },
626fcf5ef2aSThomas Huth { "r11", offsetof(CPUX86State, regs[11]) },
627fcf5ef2aSThomas Huth { "r12", offsetof(CPUX86State, regs[12]) },
628fcf5ef2aSThomas Huth { "r13", offsetof(CPUX86State, regs[13]) },
629fcf5ef2aSThomas Huth { "r14", offsetof(CPUX86State, regs[14]) },
630fcf5ef2aSThomas Huth { "r15", offsetof(CPUX86State, regs[15]) },
631fcf5ef2aSThomas Huth #endif
632fcf5ef2aSThomas Huth { "eflags", offsetof(CPUX86State, eflags) },
633fcf5ef2aSThomas Huth { "eip", offsetof(CPUX86State, eip) },
634fcf5ef2aSThomas Huth SEG("cs", R_CS)
635fcf5ef2aSThomas Huth SEG("ds", R_DS)
636fcf5ef2aSThomas Huth SEG("es", R_ES)
637fcf5ef2aSThomas Huth SEG("ss", R_SS)
638fcf5ef2aSThomas Huth SEG("fs", R_FS)
639fcf5ef2aSThomas Huth SEG("gs", R_GS)
640fcf5ef2aSThomas Huth { "pc", 0, monitor_get_pc, },
641fcf5ef2aSThomas Huth { NULL },
642fcf5ef2aSThomas Huth };
643fcf5ef2aSThomas Huth
target_monitor_defs(void)644fcf5ef2aSThomas Huth const MonitorDef *target_monitor_defs(void)
645fcf5ef2aSThomas Huth {
646fcf5ef2aSThomas Huth return monitor_defs;
647fcf5ef2aSThomas Huth }
648