gem5  v20.1.0.0
process.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Advanced Micro Devices, Inc.
3  * Copyright (c) 2007 The Hewlett-Packard Development Company
4  * All rights reserved.
5  *
6  * The license below extends only to copyright in the software and shall
7  * not be construed as granting a license to any other intellectual
8  * property including but not limited to intellectual property relating
9  * to a hardware implementation of the functionality of the software
10  * licensed hereunder. You may use the software subject to the license
11  * terms below provided that you ensure that this notice is replicated
12  * unmodified and in its entirety in all distributions of the software,
13  * modified or unmodified, in source code or in binary form.
14  *
15  * Copyright (c) 2003-2006 The Regents of The University of Michigan
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions are
20  * met: redistributions of source code must retain the above copyright
21  * notice, this list of conditions and the following disclaimer;
22  * redistributions in binary form must reproduce the above copyright
23  * notice, this list of conditions and the following disclaimer in the
24  * documentation and/or other materials provided with the distribution;
25  * neither the name of the copyright holders nor the names of its
26  * contributors may be used to endorse or promote products derived from
27  * this software without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  */
41 
42 #include "arch/x86/process.hh"
43 
44 #include <string>
45 #include <vector>
46 
47 #include "arch/x86/fs_workload.hh"
48 #include "arch/x86/isa_traits.hh"
49 #include "arch/x86/regs/misc.hh"
50 #include "arch/x86/regs/segment.hh"
51 #include "arch/x86/types.hh"
54 #include "base/logging.hh"
55 #include "base/trace.hh"
56 #include "cpu/thread_context.hh"
57 #include "debug/Stack.hh"
59 #include "mem/page_table.hh"
60 #include "params/Process.hh"
61 #include "sim/aux_vector.hh"
62 #include "sim/process_impl.hh"
63 #include "sim/syscall_desc.hh"
64 #include "sim/syscall_return.hh"
65 #include "sim/system.hh"
66 
67 using namespace std;
68 using namespace X86ISA;
69 
78 
79 X86Process::X86Process(ProcessParams *params, ::Loader::ObjectFile *objFile) :
80  Process(params, params->useArchPT ?
81  static_cast<EmulationPageTable *>(
82  new ArchPageTable(params->name, params->pid,
83  params->system, PageBytes)) :
84  new EmulationPageTable(params->name, params->pid,
85  PageBytes),
86  objFile)
87 {
88 }
89 
91  Process *p, RegVal flags)
92 {
93  Process::clone(old_tc, new_tc, p, flags);
94  X86Process *process = (X86Process*)p;
95  *process = *this;
96 }
97 
98 X86_64Process::X86_64Process(ProcessParams *params,
99  ::Loader::ObjectFile *objFile) :
100  X86Process(params, objFile)
101 {
102  vsyscallPage.base = 0xffffffffff600000ULL;
104  vsyscallPage.vtimeOffset = 0x400;
106 
107  Addr brk_point = roundUp(image.maxAddr(), PageBytes);
108  Addr stack_base = 0x7FFFFFFFF000ULL;
109  Addr max_stack_size = 8 * 1024 * 1024;
110  Addr next_thread_stack_base = stack_base - max_stack_size;
111  Addr mmap_end = 0x7FFFF7FFF000ULL;
112 
113  memState = make_shared<MemState>(this, brk_point, stack_base,
114  max_stack_size, next_thread_stack_base,
115  mmap_end);
116 }
117 
118 
119 I386Process::I386Process(ProcessParams *params,
120  ::Loader::ObjectFile *objFile) :
121  X86Process(params, objFile)
122 {
123  if (kvmInSE)
124  panic("KVM CPU model does not support 32 bit processes");
125 
126  _gdtStart = ULL(0xffffd000);
128 
129  vsyscallPage.base = 0xffffe000ULL;
133 
134  Addr brk_point = roundUp(image.maxAddr(), PageBytes);
135  Addr stack_base = _gdtStart;
136  Addr max_stack_size = 8 * 1024 * 1024;
137  Addr next_thread_stack_base = stack_base - max_stack_size;
138  Addr mmap_end = 0xB7FFF000ULL;
139 
140  memState = make_shared<MemState>(this, brk_point, stack_base,
141  max_stack_size, next_thread_stack_base,
142  mmap_end);
143 }
144 
145 void
147 {
149 
150  if (useForClone)
151  return;
152 
154 
155  // Set up the vsyscall page for this process.
156  memState->mapRegion(vsyscallPage.base, vsyscallPage.size, "vsyscall");
157  uint8_t vtimeBlob[] = {
158  0x48,0xc7,0xc0,0xc9,0x00,0x00,0x00, // mov $0xc9,%rax
159  0x0f,0x05, // syscall
160  0xc3 // retq
161  };
163  vtimeBlob, sizeof(vtimeBlob));
164 
165  uint8_t vgettimeofdayBlob[] = {
166  0x48,0xc7,0xc0,0x60,0x00,0x00,0x00, // mov $0x60,%rax
167  0x0f,0x05, // syscall
168  0xc3 // retq
169  };
170  initVirtMem->writeBlob(
172  vgettimeofdayBlob, sizeof(vgettimeofdayBlob));
173 
174  if (kvmInSE) {
175  PortProxy physProxy = system->physProxy;
176 
177  Addr syscallCodePhysAddr = system->allocPhysPages(1);
178  Addr gdtPhysAddr = system->allocPhysPages(1);
179  Addr idtPhysAddr = system->allocPhysPages(1);
180  Addr istPhysAddr = system->allocPhysPages(1);
181  Addr tssPhysAddr = system->allocPhysPages(1);
182  Addr pfHandlerPhysAddr = system->allocPhysPages(1);
183 
184  /*
185  * Set up the gdt.
186  */
187  uint8_t numGDTEntries = 0;
188  uint64_t nullDescriptor = 0;
189  physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8,
190  &nullDescriptor, 8);
191  numGDTEntries++;
192 
193  SegDescriptor initDesc = 0;
194  initDesc.type.codeOrData = 0; // code or data type
195  initDesc.type.c = 0; // conforming
196  initDesc.type.r = 1; // readable
197  initDesc.dpl = 0; // privilege
198  initDesc.p = 1; // present
199  initDesc.l = 1; // longmode - 64 bit
200  initDesc.d = 0; // operand size
201  initDesc.g = 1;
202  initDesc.s = 1; // system segment
203  initDesc.limit = 0xFFFFFFFF;
204  initDesc.base = 0;
205 
206  //64 bit code segment
207  SegDescriptor csLowPLDesc = initDesc;
208  csLowPLDesc.type.codeOrData = 1;
209  csLowPLDesc.dpl = 0;
210  uint64_t csLowPLDescVal = csLowPLDesc;
211  physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8,
212  &csLowPLDescVal, 8);
213 
214  numGDTEntries++;
215 
216  SegSelector csLowPL = 0;
217  csLowPL.si = numGDTEntries - 1;
218  csLowPL.rpl = 0;
219 
220  //64 bit data segment
221  SegDescriptor dsLowPLDesc = initDesc;
222  dsLowPLDesc.type.codeOrData = 0;
223  dsLowPLDesc.dpl = 0;
224  uint64_t dsLowPLDescVal = dsLowPLDesc;
225  physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8,
226  &dsLowPLDescVal, 8);
227 
228  numGDTEntries++;
229 
230  SegSelector dsLowPL = 0;
231  dsLowPL.si = numGDTEntries - 1;
232  dsLowPL.rpl = 0;
233 
234  //64 bit data segment
235  SegDescriptor dsDesc = initDesc;
236  dsDesc.type.codeOrData = 0;
237  dsDesc.dpl = 3;
238  uint64_t dsDescVal = dsDesc;
239  physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8,
240  &dsDescVal, 8);
241 
242  numGDTEntries++;
243 
244  SegSelector ds = 0;
245  ds.si = numGDTEntries - 1;
246  ds.rpl = 3;
247 
248  //64 bit code segment
249  SegDescriptor csDesc = initDesc;
250  csDesc.type.codeOrData = 1;
251  csDesc.dpl = 3;
252  uint64_t csDescVal = csDesc;
253  physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8,
254  &csDescVal, 8);
255 
256  numGDTEntries++;
257 
258  SegSelector cs = 0;
259  cs.si = numGDTEntries - 1;
260  cs.rpl = 3;
261 
262  SegSelector scall = 0;
263  scall.si = csLowPL.si;
264  scall.rpl = 0;
265 
266  SegSelector sret = 0;
267  sret.si = dsLowPL.si;
268  sret.rpl = 3;
269 
270  /* In long mode the TSS has been extended to 16 Bytes */
271  TSSlow TSSDescLow = 0;
272  TSSDescLow.type = 0xB;
273  TSSDescLow.dpl = 0; // Privelege level 0
274  TSSDescLow.p = 1; // Present
275  TSSDescLow.limit = 0xFFFFFFFF;
276  TSSDescLow.base = bits(TSSVirtAddr, 31, 0);
277 
278  TSShigh TSSDescHigh = 0;
279  TSSDescHigh.base = bits(TSSVirtAddr, 63, 32);
280 
281  struct TSSDesc {
282  uint64_t low;
283  uint64_t high;
284  } tssDescVal = {TSSDescLow, TSSDescHigh};
285 
286  physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8,
287  &tssDescVal, sizeof(tssDescVal));
288 
289  numGDTEntries++;
290 
291  SegSelector tssSel = 0;
292  tssSel.si = numGDTEntries - 1;
293 
294  uint64_t tss_base_addr = (TSSDescHigh.base << 32) | TSSDescLow.base;
295  uint64_t tss_limit = TSSDescLow.limit;
296 
297  SegAttr tss_attr = 0;
298 
299  tss_attr.type = TSSDescLow.type;
300  tss_attr.dpl = TSSDescLow.dpl;
301  tss_attr.present = TSSDescLow.p;
302  tss_attr.granularity = TSSDescLow.g;
303  tss_attr.unusable = 0;
304 
305  for (int i = 0; i < contextIds.size(); i++) {
307 
308  tc->setMiscReg(MISCREG_CS, cs);
309  tc->setMiscReg(MISCREG_DS, ds);
310  tc->setMiscReg(MISCREG_ES, ds);
311  tc->setMiscReg(MISCREG_FS, ds);
312  tc->setMiscReg(MISCREG_GS, ds);
313  tc->setMiscReg(MISCREG_SS, ds);
314 
315  // LDT
316  tc->setMiscReg(MISCREG_TSL, 0);
317  SegAttr tslAttr = 0;
318  tslAttr.present = 1;
319  tslAttr.type = 2;
320  tc->setMiscReg(MISCREG_TSL_ATTR, tslAttr);
321 
323  tc->setMiscReg(MISCREG_TSG_LIMIT, 8 * numGDTEntries - 1);
324 
325  tc->setMiscReg(MISCREG_TR, tssSel);
326  tc->setMiscReg(MISCREG_TR_BASE, tss_base_addr);
328  tc->setMiscReg(MISCREG_TR_LIMIT, tss_limit);
329  tc->setMiscReg(MISCREG_TR_ATTR, tss_attr);
330 
331  //Start using longmode segments.
332  installSegDesc(tc, SEGMENT_REG_CS, csDesc, true);
333  installSegDesc(tc, SEGMENT_REG_DS, dsDesc, true);
334  installSegDesc(tc, SEGMENT_REG_ES, dsDesc, true);
335  installSegDesc(tc, SEGMENT_REG_FS, dsDesc, true);
336  installSegDesc(tc, SEGMENT_REG_GS, dsDesc, true);
337  installSegDesc(tc, SEGMENT_REG_SS, dsDesc, true);
338 
339  Efer efer = 0;
340  efer.sce = 1; // Enable system call extensions.
341  efer.lme = 1; // Enable long mode.
342  efer.lma = 1; // Activate long mode.
343  efer.nxe = 1; // Enable nx support.
344  efer.svme = 0; // Enable svm support for now.
345  efer.ffxsr = 0; // Turn on fast fxsave and fxrstor.
346  tc->setMiscReg(MISCREG_EFER, efer);
347 
348  //Set up the registers that describe the operating mode.
349  CR0 cr0 = 0;
350  cr0.pg = 1; // Turn on paging.
351  cr0.cd = 0; // Don't disable caching.
352  cr0.nw = 0; // This is bit is defined to be ignored.
353  cr0.am = 1; // No alignment checking
354  cr0.wp = 1; // Supervisor mode can write read only pages
355  cr0.ne = 1;
356  cr0.et = 1; // This should always be 1
357  cr0.ts = 0; // We don't do task switching, so causing fp exceptions
358  // would be pointless.
359  cr0.em = 0; // Allow x87 instructions to execute natively.
360  cr0.mp = 1; // This doesn't really matter, but the manual suggests
361  // setting it to one.
362  cr0.pe = 1; // We're definitely in protected mode.
363  tc->setMiscReg(MISCREG_CR0, cr0);
364 
365  CR0 cr2 = 0;
366  tc->setMiscReg(MISCREG_CR2, cr2);
367 
368  CR3 cr3 = dynamic_cast<ArchPageTable *>(pTable)->basePtr();
369  tc->setMiscReg(MISCREG_CR3, cr3);
370 
371  CR4 cr4 = 0;
372  //Turn on pae.
373  cr4.osxsave = 0; // Enable XSAVE and Proc Extended States
374  cr4.osxmmexcpt = 0; // Operating System Unmasked Exception
375  cr4.osfxsr = 1; // Operating System FXSave/FSRSTOR Support
376  cr4.pce = 0; // Performance-Monitoring Counter Enable
377  cr4.pge = 0; // Page-Global Enable
378  cr4.mce = 0; // Machine Check Enable
379  cr4.pae = 1; // Physical-Address Extension
380  cr4.pse = 0; // Page Size Extensions
381  cr4.de = 0; // Debugging Extensions
382  cr4.tsd = 0; // Time Stamp Disable
383  cr4.pvi = 0; // Protected-Mode Virtual Interrupts
384  cr4.vme = 0; // Virtual-8086 Mode Extensions
385 
386  tc->setMiscReg(MISCREG_CR4, cr4);
387 
388  CR4 cr8 = 0;
389  tc->setMiscReg(MISCREG_CR8, cr8);
390 
391  tc->setMiscReg(MISCREG_MXCSR, 0x1f80);
392 
393  tc->setMiscReg(MISCREG_APIC_BASE, 0xfee00900);
394 
396  tc->setMiscReg(MISCREG_TSG_LIMIT, 0xffff);
397 
399  tc->setMiscReg(MISCREG_IDTR_LIMIT, 0xffff);
400 
401  /* enabling syscall and sysret */
402  RegVal star = ((RegVal)sret << 48) | ((RegVal)scall << 32);
403  tc->setMiscReg(MISCREG_STAR, star);
405  tc->setMiscReg(MISCREG_LSTAR, lstar);
406  RegVal sfmask = (1 << 8) | (1 << 10); // TF | DF
407  tc->setMiscReg(MISCREG_SF_MASK, sfmask);
408  }
409 
410  /* Set up the content of the TSS and write it to physical memory. */
411 
412  struct {
413  uint32_t reserved0; // +00h
414  uint32_t RSP0_low; // +04h
415  uint32_t RSP0_high; // +08h
416  uint32_t RSP1_low; // +0Ch
417  uint32_t RSP1_high; // +10h
418  uint32_t RSP2_low; // +14h
419  uint32_t RSP2_high; // +18h
420  uint32_t reserved1; // +1Ch
421  uint32_t reserved2; // +20h
422  uint32_t IST1_low; // +24h
423  uint32_t IST1_high; // +28h
424  uint32_t IST2_low; // +2Ch
425  uint32_t IST2_high; // +30h
426  uint32_t IST3_low; // +34h
427  uint32_t IST3_high; // +38h
428  uint32_t IST4_low; // +3Ch
429  uint32_t IST4_high; // +40h
430  uint32_t IST5_low; // +44h
431  uint32_t IST5_high; // +48h
432  uint32_t IST6_low; // +4Ch
433  uint32_t IST6_high; // +50h
434  uint32_t IST7_low; // +54h
435  uint32_t IST7_high; // +58h
436  uint32_t reserved3; // +5Ch
437  uint32_t reserved4; // +60h
438  uint16_t reserved5; // +64h
439  uint16_t IO_MapBase; // +66h
440  } tss;
441 
443  uint64_t IST_start = ISTVirtAddr + PageBytes;
444  tss.IST1_low = IST_start;
445  tss.IST1_high = IST_start >> 32;
446  tss.RSP0_low = tss.IST1_low;
447  tss.RSP0_high = tss.IST1_high;
448  tss.RSP1_low = tss.IST1_low;
449  tss.RSP1_high = tss.IST1_high;
450  tss.RSP2_low = tss.IST1_low;
451  tss.RSP2_high = tss.IST1_high;
452  physProxy.writeBlob(tssPhysAddr, &tss, sizeof(tss));
453 
454  /* Setting IDT gates */
455  GateDescriptorLow PFGateLow = 0;
456  PFGateLow.offsetHigh = bits(PFHandlerVirtAddr, 31, 16);
457  PFGateLow.offsetLow = bits(PFHandlerVirtAddr, 15, 0);
458  PFGateLow.selector = csLowPL;
459  PFGateLow.p = 1;
460  PFGateLow.dpl = 0;
461  PFGateLow.type = 0xe; // gate interrupt type
462  PFGateLow.IST = 0; // setting IST to 0 and using RSP0
463 
464  GateDescriptorHigh PFGateHigh = 0;
465  PFGateHigh.offset = bits(PFHandlerVirtAddr, 63, 32);
466 
467  struct {
468  uint64_t low;
469  uint64_t high;
470  } PFGate = {PFGateLow, PFGateHigh};
471 
472  physProxy.writeBlob(idtPhysAddr + 0xE0, &PFGate, sizeof(PFGate));
473 
474  /* System call handler */
475  uint8_t syscallBlob[] = {
476  // mov %rax, (0xffffc90000005600)
477  0x48, 0xa3, 0x00, 0x60, 0x00,
478  0x00, 0x00, 0xc9, 0xff, 0xff,
479  // sysret
480  0x48, 0x0f, 0x07
481  };
482 
483  physProxy.writeBlob(syscallCodePhysAddr,
484  syscallBlob, sizeof(syscallBlob));
485 
487  uint8_t faultBlob[] = {
488  // mov %rax, (0xffffc90000005700)
489  0x48, 0xa3, 0x00, 0x61, 0x00,
490  0x00, 0x00, 0xc9, 0xff, 0xff,
491  // add $0x8, %rsp # skip error
492  0x48, 0x83, 0xc4, 0x08,
493  // iretq
494  0x48, 0xcf
495  };
496 
497  physProxy.writeBlob(pfHandlerPhysAddr, faultBlob, sizeof(faultBlob));
498 
499  /* Syscall handler */
500  pTable->map(syscallCodeVirtAddr, syscallCodePhysAddr,
501  PageBytes, false);
502  /* GDT */
503  pTable->map(GDTVirtAddr, gdtPhysAddr, PageBytes, false);
504  /* IDT */
505  pTable->map(IDTVirtAddr, idtPhysAddr, PageBytes, false);
506  /* TSS */
507  pTable->map(TSSVirtAddr, tssPhysAddr, PageBytes, false);
508  /* IST */
509  pTable->map(ISTVirtAddr, istPhysAddr, PageBytes, false);
510  /* PF handler */
511  pTable->map(PFHandlerVirtAddr, pfHandlerPhysAddr, PageBytes, false);
512  /* MMIO region for m5ops */
514  16 * PageBytes, false);
515  } else {
516  for (int i = 0; i < contextIds.size(); i++) {
518 
519  SegAttr dataAttr = 0;
520  dataAttr.dpl = 3;
521  dataAttr.unusable = 0;
522  dataAttr.defaultSize = 1;
523  dataAttr.longMode = 1;
524  dataAttr.avl = 0;
525  dataAttr.granularity = 1;
526  dataAttr.present = 1;
527  dataAttr.type = 3;
528  dataAttr.writable = 1;
529  dataAttr.readable = 1;
530  dataAttr.expandDown = 0;
531  dataAttr.system = 1;
532 
533  // Initialize the segment registers.
534  for (int seg = 0; seg < NUM_SEGMENTREGS; seg++) {
537  tc->setMiscRegNoEffect(MISCREG_SEG_ATTR(seg), dataAttr);
538  }
539 
540  SegAttr csAttr = 0;
541  csAttr.dpl = 3;
542  csAttr.unusable = 0;
543  csAttr.defaultSize = 0;
544  csAttr.longMode = 1;
545  csAttr.avl = 0;
546  csAttr.granularity = 1;
547  csAttr.present = 1;
548  csAttr.type = 10;
549  csAttr.writable = 0;
550  csAttr.readable = 1;
551  csAttr.expandDown = 0;
552  csAttr.system = 1;
553 
554  tc->setMiscRegNoEffect(MISCREG_CS_ATTR, csAttr);
555 
556  Efer efer = 0;
557  efer.sce = 1; // Enable system call extensions.
558  efer.lme = 1; // Enable long mode.
559  efer.lma = 1; // Activate long mode.
560  efer.nxe = 1; // Enable nx support.
561  efer.svme = 0; // Disable svm support for now. It isn't implemented.
562  efer.ffxsr = 1; // Turn on fast fxsave and fxrstor.
563  tc->setMiscReg(MISCREG_EFER, efer);
564 
565  // Set up the registers that describe the operating mode.
566  CR0 cr0 = 0;
567  cr0.pg = 1; // Turn on paging.
568  cr0.cd = 0; // Don't disable caching.
569  cr0.nw = 0; // This is bit is defined to be ignored.
570  cr0.am = 0; // No alignment checking
571  cr0.wp = 0; // Supervisor mode can write read only pages
572  cr0.ne = 1;
573  cr0.et = 1; // This should always be 1
574  cr0.ts = 0; // We don't do task switching, so causing fp exceptions
575  // would be pointless.
576  cr0.em = 0; // Allow x87 instructions to execute natively.
577  cr0.mp = 1; // This doesn't really matter, but the manual suggests
578  // setting it to one.
579  cr0.pe = 1; // We're definitely in protected mode.
580  tc->setMiscReg(MISCREG_CR0, cr0);
581 
582  tc->setMiscReg(MISCREG_MXCSR, 0x1f80);
583  }
584  }
585 }
586 
587 void
589 {
591 
593 
594  /*
595  * Set up a GDT for this process. The whole GDT wouldn't really be for
596  * this process, but the only parts we care about are.
597  */
599  uint64_t zero = 0;
600  assert(_gdtSize % sizeof(zero) == 0);
601  for (Addr gdtCurrent = _gdtStart;
602  gdtCurrent < _gdtStart + _gdtSize; gdtCurrent += sizeof(zero)) {
603  initVirtMem->write(gdtCurrent, zero);
604  }
605 
606  // Set up the vsyscall page for this process.
607  memState->mapRegion(vsyscallPage.base, vsyscallPage.size, "vsyscall");
608  uint8_t vsyscallBlob[] = {
609  0x51, // push %ecx
610  0x52, // push %edp
611  0x55, // push %ebp
612  0x89, 0xe5, // mov %esp, %ebp
613  0x0f, 0x34 // sysenter
614  };
616  vsyscallBlob, sizeof(vsyscallBlob));
617 
618  uint8_t vsysexitBlob[] = {
619  0x5d, // pop %ebp
620  0x5a, // pop %edx
621  0x59, // pop %ecx
622  0xc3 // ret
623  };
625  vsysexitBlob, sizeof(vsysexitBlob));
626 
627  for (int i = 0; i < contextIds.size(); i++) {
629 
630  SegAttr dataAttr = 0;
631  dataAttr.dpl = 3;
632  dataAttr.unusable = 0;
633  dataAttr.defaultSize = 1;
634  dataAttr.longMode = 0;
635  dataAttr.avl = 0;
636  dataAttr.granularity = 1;
637  dataAttr.present = 1;
638  dataAttr.type = 3;
639  dataAttr.writable = 1;
640  dataAttr.readable = 1;
641  dataAttr.expandDown = 0;
642  dataAttr.system = 1;
643 
644  // Initialize the segment registers.
645  for (int seg = 0; seg < NUM_SEGMENTREGS; seg++) {
648  tc->setMiscRegNoEffect(MISCREG_SEG_ATTR(seg), dataAttr);
650  tc->setMiscRegNoEffect(MISCREG_SEG_LIMIT(seg), (uint32_t)(-1));
651  }
652 
653  SegAttr csAttr = 0;
654  csAttr.dpl = 3;
655  csAttr.unusable = 0;
656  csAttr.defaultSize = 1;
657  csAttr.longMode = 0;
658  csAttr.avl = 0;
659  csAttr.granularity = 1;
660  csAttr.present = 1;
661  csAttr.type = 0xa;
662  csAttr.writable = 0;
663  csAttr.readable = 1;
664  csAttr.expandDown = 0;
665  csAttr.system = 1;
666 
667  tc->setMiscRegNoEffect(MISCREG_CS_ATTR, csAttr);
668 
672 
673  // Set the LDT selector to 0 to deactivate it.
675 
676  Efer efer = 0;
677  efer.sce = 1; // Enable system call extensions.
678  efer.lme = 1; // Enable long mode.
679  efer.lma = 0; // Deactivate long mode.
680  efer.nxe = 1; // Enable nx support.
681  efer.svme = 0; // Disable svm support for now. It isn't implemented.
682  efer.ffxsr = 1; // Turn on fast fxsave and fxrstor.
683  tc->setMiscReg(MISCREG_EFER, efer);
684 
685  // Set up the registers that describe the operating mode.
686  CR0 cr0 = 0;
687  cr0.pg = 1; // Turn on paging.
688  cr0.cd = 0; // Don't disable caching.
689  cr0.nw = 0; // This is bit is defined to be ignored.
690  cr0.am = 0; // No alignment checking
691  cr0.wp = 0; // Supervisor mode can write read only pages
692  cr0.ne = 1;
693  cr0.et = 1; // This should always be 1
694  cr0.ts = 0; // We don't do task switching, so causing fp exceptions
695  // would be pointless.
696  cr0.em = 0; // Allow x87 instructions to execute natively.
697  cr0.mp = 1; // This doesn't really matter, but the manual suggests
698  // setting it to one.
699  cr0.pe = 1; // We're definitely in protected mode.
700  tc->setMiscReg(MISCREG_CR0, cr0);
701 
702  tc->setMiscReg(MISCREG_MXCSR, 0x1f80);
703  }
704 }
705 
706 template<class IntType>
707 void
708 X86Process::argsInit(int pageSize,
709  std::vector<AuxVector<IntType> > extraAuxvs)
710 {
711  int intSize = sizeof(IntType);
712 
713  std::vector<AuxVector<IntType>> auxv = extraAuxvs;
714 
715  string filename;
716  if (argv.size() < 1)
717  filename = "";
718  else
719  filename = argv[0];
720 
721  // We want 16 byte alignment
722  uint64_t align = 16;
723 
724  enum X86CpuFeature {
725  X86_OnboardFPU = 1 << 0,
726  X86_VirtualModeExtensions = 1 << 1,
727  X86_DebuggingExtensions = 1 << 2,
728  X86_PageSizeExtensions = 1 << 3,
729 
730  X86_TimeStampCounter = 1 << 4,
731  X86_ModelSpecificRegisters = 1 << 5,
732  X86_PhysicalAddressExtensions = 1 << 6,
733  X86_MachineCheckExtensions = 1 << 7,
734 
735  X86_CMPXCHG8Instruction = 1 << 8,
736  X86_OnboardAPIC = 1 << 9,
737  X86_SYSENTER_SYSEXIT = 1 << 11,
738 
739  X86_MemoryTypeRangeRegisters = 1 << 12,
740  X86_PageGlobalEnable = 1 << 13,
741  X86_MachineCheckArchitecture = 1 << 14,
742  X86_CMOVInstruction = 1 << 15,
743 
744  X86_PageAttributeTable = 1 << 16,
745  X86_36BitPSEs = 1 << 17,
746  X86_ProcessorSerialNumber = 1 << 18,
747  X86_CLFLUSHInstruction = 1 << 19,
748 
749  X86_DebugTraceStore = 1 << 21,
750  X86_ACPIViaMSR = 1 << 22,
751  X86_MultimediaExtensions = 1 << 23,
752 
753  X86_FXSAVE_FXRSTOR = 1 << 24,
754  X86_StreamingSIMDExtensions = 1 << 25,
755  X86_StreamingSIMDExtensions2 = 1 << 26,
756  X86_CPUSelfSnoop = 1 << 27,
757 
758  X86_HyperThreading = 1 << 28,
759  X86_AutomaticClockControl = 1 << 29,
760  X86_IA64Processor = 1 << 30
761  };
762 
763  // Setup the auxiliary vectors. These will already have endian
764  // conversion. Auxiliary vectors are loaded only for elf formatted
765  // executables; the auxv is responsible for passing information from
766  // the OS to the interpreter.
767  auto *elfObject = dynamic_cast<::Loader::ElfObject *>(objFile);
768  if (elfObject) {
769  uint64_t features =
770  X86_OnboardFPU |
771  X86_VirtualModeExtensions |
772  X86_DebuggingExtensions |
773  X86_PageSizeExtensions |
774  X86_TimeStampCounter |
775  X86_ModelSpecificRegisters |
776  X86_PhysicalAddressExtensions |
777  X86_MachineCheckExtensions |
778  X86_CMPXCHG8Instruction |
779  X86_OnboardAPIC |
780  X86_SYSENTER_SYSEXIT |
781  X86_MemoryTypeRangeRegisters |
782  X86_PageGlobalEnable |
783  X86_MachineCheckArchitecture |
784  X86_CMOVInstruction |
785  X86_PageAttributeTable |
786  X86_36BitPSEs |
787 // X86_ProcessorSerialNumber |
788  X86_CLFLUSHInstruction |
789 // X86_DebugTraceStore |
790 // X86_ACPIViaMSR |
791  X86_MultimediaExtensions |
792  X86_FXSAVE_FXRSTOR |
793  X86_StreamingSIMDExtensions |
794  X86_StreamingSIMDExtensions2 |
795 // X86_CPUSelfSnoop |
796 // X86_HyperThreading |
797 // X86_AutomaticClockControl |
798 // X86_IA64Processor |
799  0;
800 
801  // Bits which describe the system hardware capabilities
802  // XXX Figure out what these should be
803  auxv.emplace_back(M5_AT_HWCAP, features);
804  // The system page size
805  auxv.emplace_back(M5_AT_PAGESZ, X86ISA::PageBytes);
806  // Frequency at which times() increments
807  // Defined to be 100 in the kernel source.
808  auxv.emplace_back(M5_AT_CLKTCK, 100);
809  // This is the virtual address of the program header tables if they
810  // appear in the executable image.
811  auxv.emplace_back(M5_AT_PHDR, elfObject->programHeaderTable());
812  // This is the size of a program header entry from the elf file.
813  auxv.emplace_back(M5_AT_PHENT, elfObject->programHeaderSize());
814  // This is the number of program headers from the original elf file.
815  auxv.emplace_back(M5_AT_PHNUM, elfObject->programHeaderCount());
816  // This is the base address of the ELF interpreter; it should be
817  // zero for static executables or contain the base address for
818  // dynamic executables.
819  auxv.emplace_back(M5_AT_BASE, getBias());
820  // XXX Figure out what this should be.
821  auxv.emplace_back(M5_AT_FLAGS, 0);
822  // The entry point to the program
823  auxv.emplace_back(M5_AT_ENTRY, objFile->entryPoint());
824  // Different user and group IDs
825  auxv.emplace_back(M5_AT_UID, uid());
826  auxv.emplace_back(M5_AT_EUID, euid());
827  auxv.emplace_back(M5_AT_GID, gid());
828  auxv.emplace_back(M5_AT_EGID, egid());
829  // Whether to enable "secure mode" in the executable
830  auxv.emplace_back(M5_AT_SECURE, 0);
831  // The address of 16 "random" bytes.
832  auxv.emplace_back(M5_AT_RANDOM, 0);
833  // The name of the program
834  auxv.emplace_back(M5_AT_EXECFN, 0);
835  // The platform string
836  auxv.emplace_back(M5_AT_PLATFORM, 0);
837  }
838 
839  // Figure out how big the initial stack needs to be
840 
841  // A sentry NULL void pointer at the top of the stack.
842  int sentry_size = intSize;
843 
844  // This is the name of the file which is present on the initial stack
845  // It's purpose is to let the user space linker examine the original file.
846  int file_name_size = filename.size() + 1;
847 
848  const int numRandomBytes = 16;
849  int aux_data_size = numRandomBytes;
850 
851  string platform = "x86_64";
852  aux_data_size += platform.size() + 1;
853 
854  int env_data_size = 0;
855  for (int i = 0; i < envp.size(); ++i)
856  env_data_size += envp[i].size() + 1;
857  int arg_data_size = 0;
858  for (int i = 0; i < argv.size(); ++i)
859  arg_data_size += argv[i].size() + 1;
860 
861  // The info_block needs to be padded so its size is a multiple of the
862  // alignment mask. Also, it appears that there needs to be at least some
863  // padding, so if the size is already a multiple, we need to increase it
864  // anyway.
865  int base_info_block_size =
866  sentry_size + file_name_size + env_data_size + arg_data_size;
867 
868  int info_block_size = roundUp(base_info_block_size, align);
869 
870  int info_block_padding = info_block_size - base_info_block_size;
871 
872  // Each auxiliary vector is two 8 byte words
873  int aux_array_size = intSize * 2 * (auxv.size() + 1);
874 
875  int envp_array_size = intSize * (envp.size() + 1);
876  int argv_array_size = intSize * (argv.size() + 1);
877 
878  int argc_size = intSize;
879 
880  // Figure out the size of the contents of the actual initial frame
881  int frame_size =
882  aux_array_size +
883  envp_array_size +
884  argv_array_size +
885  argc_size;
886 
887  // There needs to be padding after the auxiliary vector data so that the
888  // very bottom of the stack is aligned properly.
889  int partial_size = frame_size + aux_data_size;
890  int aligned_partial_size = roundUp(partial_size, align);
891  int aux_padding = aligned_partial_size - partial_size;
892 
893  int space_needed =
894  info_block_size +
895  aux_data_size +
896  aux_padding +
897  frame_size;
898 
899  Addr stack_base = memState->getStackBase();
900 
901  Addr stack_min = stack_base - space_needed;
902  stack_min = roundDown(stack_min, align);
903 
904  unsigned stack_size = stack_base - stack_min;
905  stack_size = roundUp(stack_size, pageSize);
906  memState->setStackSize(stack_size);
907 
908  // map memory
909  Addr stack_end = roundDown(stack_base - stack_size, pageSize);
910 
911  DPRINTF(Stack, "Mapping the stack: 0x%x %dB\n", stack_end, stack_size);
912  memState->mapRegion(stack_end, stack_size, "stack");
913 
914  // map out initial stack contents
915  IntType sentry_base = stack_base - sentry_size;
916  IntType file_name_base = sentry_base - file_name_size;
917  IntType env_data_base = file_name_base - env_data_size;
918  IntType arg_data_base = env_data_base - arg_data_size;
919  IntType aux_data_base = arg_data_base - info_block_padding - aux_data_size;
920  IntType auxv_array_base = aux_data_base - aux_array_size - aux_padding;
921  IntType envp_array_base = auxv_array_base - envp_array_size;
922  IntType argv_array_base = envp_array_base - argv_array_size;
923  IntType argc_base = argv_array_base - argc_size;
924 
925  DPRINTF(Stack, "The addresses of items on the initial stack:\n");
926  DPRINTF(Stack, "0x%x - file name\n", file_name_base);
927  DPRINTF(Stack, "0x%x - env data\n", env_data_base);
928  DPRINTF(Stack, "0x%x - arg data\n", arg_data_base);
929  DPRINTF(Stack, "0x%x - aux data\n", aux_data_base);
930  DPRINTF(Stack, "0x%x - auxv array\n", auxv_array_base);
931  DPRINTF(Stack, "0x%x - envp array\n", envp_array_base);
932  DPRINTF(Stack, "0x%x - argv array\n", argv_array_base);
933  DPRINTF(Stack, "0x%x - argc \n", argc_base);
934  DPRINTF(Stack, "0x%x - stack min\n", stack_min);
935 
936  // write contents to stack
937 
938  // figure out argc
939  IntType argc = argv.size();
940  IntType guestArgc = htole(argc);
941 
942  // Write out the sentry void *
943  IntType sentry_NULL = 0;
944  initVirtMem->writeBlob(sentry_base, &sentry_NULL, sentry_size);
945 
946  // Write the file name
947  initVirtMem->writeString(file_name_base, filename.c_str());
948 
949  // Fix up the aux vectors which point to data
950  assert(auxv[auxv.size() - 3].type == M5_AT_RANDOM);
951  auxv[auxv.size() - 3].val = aux_data_base;
952  assert(auxv[auxv.size() - 2].type == M5_AT_EXECFN);
953  auxv[auxv.size() - 2].val = argv_array_base;
954  assert(auxv[auxv.size() - 1].type == M5_AT_PLATFORM);
955  auxv[auxv.size() - 1].val = aux_data_base + numRandomBytes;
956 
957 
958  // Copy the aux stuff
959  Addr auxv_array_end = auxv_array_base;
960  for (const auto &aux: auxv) {
961  initVirtMem->write(auxv_array_end, aux, GuestByteOrder);
962  auxv_array_end += sizeof(aux);
963  }
964  // Write out the terminating zeroed auxiliary vector
965  const AuxVector<uint64_t> zero(0, 0);
966  initVirtMem->write(auxv_array_end, zero);
967  auxv_array_end += sizeof(zero);
968 
969  initVirtMem->writeString(aux_data_base, platform.c_str());
970 
971  copyStringArray(envp, envp_array_base, env_data_base,
972  ByteOrder::little, *initVirtMem);
973  copyStringArray(argv, argv_array_base, arg_data_base,
974  ByteOrder::little, *initVirtMem);
975 
976  initVirtMem->writeBlob(argc_base, &guestArgc, intSize);
977 
979  // Set the stack pointer register
980  tc->setIntReg(StackPointerReg, stack_min);
981 
982  // There doesn't need to be any segment base added in since we're dealing
983  // with the flat segmentation model.
984  tc->pcState(getStartPC());
985 
986  // Align the "stack_min" to a page boundary.
987  memState->setStackMin(roundDown(stack_min, pageSize));
988 }
989 
990 void
992 {
993  std::vector<AuxVector<uint64_t> > extraAuxvs;
994  extraAuxvs.emplace_back(M5_AT_SYSINFO_EHDR, vsyscallPage.base);
995  X86Process::argsInit<uint64_t>(pageSize, extraAuxvs);
996 }
997 
998 void
1000 {
1001  std::vector<AuxVector<uint32_t> > extraAuxvs;
1002  //Tell the binary where the vsyscall part of the vsyscall page is.
1003  extraAuxvs.emplace_back(M5_AT_SYSINFO,
1005  extraAuxvs.emplace_back(M5_AT_SYSINFO_EHDR, vsyscallPage.base);
1006  X86Process::argsInit<uint32_t>(pageSize, extraAuxvs);
1007 }
1008 
1009 void
1011  Process *p, RegVal flags)
1012 {
1013  X86Process::clone(old_tc, new_tc, p, flags);
1014  ((X86_64Process*)p)->vsyscallPage = vsyscallPage;
1015 }
1016 
1017 void
1019  Process *p, RegVal flags)
1020 {
1021  X86Process::clone(old_tc, new_tc, p, flags);
1022  ((I386Process*)p)->vsyscallPage = vsyscallPage;
1023 }
X86ISA::GDTVirtAddr
const Addr GDTVirtAddr
Definition: fs_workload.hh:70
X86ISA::M5_AT_SYSINFO_EHDR
@ M5_AT_SYSINFO_EHDR
Definition: process.hh:55
roundDown
T roundDown(const T &val, const U &align)
This function is used to align addresses in memory.
Definition: intmath.hh:150
X86ISA::X86Process
Definition: process.hh:58
Process::kvmInSE
bool kvmInSE
Definition: process.hh:170
X86ISA::MISCREG_APIC_BASE
@ MISCREG_APIC_BASE
Definition: misc.hh:393
MipsISA::ds
Bitfield< 15, 13 > ds
Definition: pra_constants.hh:235
X86ISA::MISCREG_TSG_LIMIT
@ MISCREG_TSG_LIMIT
Definition: misc.hh:354
system.hh
Process::envp
std::vector< std::string > envp
Definition: process.hh:217
Process::useForClone
bool useForClone
Definition: process.hh:172
X86ISA::SEGMENT_REG_FS
@ SEGMENT_REG_FS
Definition: segment.hh:49
Process::gid
uint64_t gid()
Definition: process.hh:82
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
System::physProxy
PortProxy physProxy
Port to physical memory used for writing object files into ram at boot.
Definition: system.hh:324
X86ISA::I386Process::initState
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
Definition: process.cc:588
Process
Definition: process.hh:65
M5_AT_UID
@ M5_AT_UID
Definition: aux_vector.hh:69
X86ISA::MISCREG_TSL
@ MISCREG_TSL
Definition: misc.hh:303
X86ISA::MISCREG_TR_EFF_BASE
@ MISCREG_TR_EFF_BASE
Definition: misc.hh:341
X86ISA::MISCREG_ES
@ MISCREG_ES
Definition: misc.hh:296
X86ISA::I386Process::VSyscallPage::vsyscallOffset
Addr vsyscallOffset
Definition: process.hh:138
X86ISA::MISCREG_TR_LIMIT
@ MISCREG_TR_LIMIT
Definition: misc.hh:357
htole
T htole(T value)
Definition: byteswap.hh:140
X86ISA::MISCREG_CS
@ MISCREG_CS
Definition: misc.hh:297
X86ISA::X86Process::clone
void clone(ThreadContext *old_tc, ThreadContext *new_tc, Process *process, RegVal flags) override
Definition: process.cc:90
Process::argv
std::vector< std::string > argv
Definition: process.hh:216
ThreadContext::setIntReg
virtual void setIntReg(RegIndex reg_idx, RegVal val)=0
X86ISA::MISCREG_SEG_LIMIT
static MiscRegIndex MISCREG_SEG_LIMIT(int index)
Definition: misc.hh:526
M5_AT_PAGESZ
@ M5_AT_PAGESZ
Definition: aux_vector.hh:64
M5_AT_SECURE
@ M5_AT_SECURE
Definition: aux_vector.hh:76
X86ISA::MISCREG_CR2
@ MISCREG_CR2
Definition: misc.hh:107
Process::pTable
EmulationPageTable * pTable
Definition: process.hh:174
M5_AT_PHENT
@ M5_AT_PHENT
Definition: aux_vector.hh:62
ArchPageTable
MultiLevelPageTable< LongModePTE< 47, 39 >, LongModePTE< 38, 30 >, LongModePTE< 29, 21 >, LongModePTE< 20, 12 > > ArchPageTable
Definition: process.cc:77
process_impl.hh
M5_AT_EUID
@ M5_AT_EUID
Definition: aux_vector.hh:70
std::vector
STL vector class.
Definition: stl.hh:37
Process::initVirtMem
std::unique_ptr< SETranslatingPortProxy > initVirtMem
Definition: process.hh:177
X86ISA::MISCREG_EFER
@ MISCREG_EFER
Definition: misc.hh:245
X86ISA::M5_AT_SYSINFO
@ M5_AT_SYSINFO
Definition: process.hh:54
Process::egid
uint64_t egid()
Definition: process.hh:83
Loader::ElfObject
Definition: elf_object.hh:59
X86ISA::I386Process::VSyscallPage::vsysexitOffset
Addr vsysexitOffset
Definition: process.hh:139
Loader::MemoryImage::maxAddr
Addr maxAddr() const
Definition: memory_image.hh:131
sc_dt::align
void align(const scfx_rep &lhs, const scfx_rep &rhs, int &new_wp, int &len_mant, scfx_mant_ref &lhs_mant, scfx_mant_ref &rhs_mant)
Definition: scfx_rep.cc:2083
X86ISA::MISCREG_TR_ATTR
@ MISCREG_TR_ATTR
Definition: misc.hh:373
X86ISA::MISCREG_SEG_SEL
static MiscRegIndex MISCREG_SEG_SEL(int index)
Definition: misc.hh:505
X86ISA::MISCREG_TR_BASE
@ MISCREG_TR_BASE
Definition: misc.hh:323
X86ISA::I386Process::VSyscallPage::size
Addr size
Definition: process.hh:137
X86ISA::X86_64Process::VSyscallPage::size
Addr size
Definition: process.hh:100
M5_AT_ENTRY
@ M5_AT_ENTRY
Definition: aux_vector.hh:67
PortProxy::writeBlob
void writeBlob(Addr addr, const void *p, int size) const
Same as tryWriteBlob, but insists on success.
Definition: port_proxy.hh:187
X86ISA::MISCREG_STAR
@ MISCREG_STAR
Definition: misc.hh:247
M5_AT_BASE
@ M5_AT_BASE
Definition: aux_vector.hh:65
X86ISA::system
Bitfield< 15 > system
Definition: misc.hh:997
Loader::ObjectFile
Definition: object_file.hh:70
M5_AT_PHNUM
@ M5_AT_PHNUM
Definition: aux_vector.hh:63
X86ISA::X86_64Process
Definition: process.hh:93
X86ISA::MISCREG_DS
@ MISCREG_DS
Definition: misc.hh:299
elf_object.hh
AuxVector
Definition: aux_vector.hh:38
X86ISA::MISCREG_CR4
@ MISCREG_CR4
Definition: misc.hh:109
Loader::ObjectFile::entryPoint
Addr entryPoint() const
Definition: object_file.hh:108
syscall_return.hh
X86ISA::X86_64Process::vsyscallPage
VSyscallPage vsyscallPage
Definition: process.hh:118
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
X86ISA::I386Process
Definition: process.hh:130
Process::clone
virtual void clone(ThreadContext *old_tc, ThreadContext *new_tc, Process *new_p, RegVal flags)
Definition: process.cc:163
M5_AT_PLATFORM
@ M5_AT_PLATFORM
Definition: aux_vector.hh:73
EmulationPageTable
Definition: page_table.hh:48
multi_level_page_table.hh
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:234
MultiLevelPageTable
Definition: multi_level_page_table.hh:179
Process::allocateMem
void allocateMem(Addr vaddr, int64_t size, bool clobber=false)
Definition: process.cc:319
X86ISA::I386Process::argsInit
void argsInit(int pageSize)
Definition: process.cc:999
segment.hh
X86ISA::X86Process::_gdtStart
Addr _gdtStart
Definition: process.hh:61
M5_AT_FLAGS
@ M5_AT_FLAGS
Definition: aux_vector.hh:66
X86ISA::PageBytes
const Addr PageBytes
Definition: isa_traits.hh:48
X86ISA::LongModePTE
Definition: pagetable.hh:155
isa_traits.hh
X86ISA::syscallCodeVirtAddr
const Addr syscallCodeVirtAddr
Definition: fs_workload.hh:69
X86ISA::X86_64Process::argsInit
void argsInit(int pageSize)
Definition: process.cc:991
X86ISA::MMIORegionPhysAddr
const Addr MMIORegionPhysAddr
Definition: fs_workload.hh:77
X86ISA::MISCREG_SEG_ATTR
static MiscRegIndex MISCREG_SEG_ATTR(int index)
Definition: misc.hh:533
M5_AT_EXECFN
@ M5_AT_EXECFN
Definition: aux_vector.hh:80
X86ISA::IDTVirtAddr
const Addr IDTVirtAddr
Definition: fs_workload.hh:71
Process::image
::Loader::MemoryImage image
Definition: process.hh:214
M5_AT_RANDOM
@ M5_AT_RANDOM
Definition: aux_vector.hh:78
X86ISA
This is exposed globally, independent of the ISA.
Definition: acpi.hh:55
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
X86ISA::PFHandlerVirtAddr
const Addr PFHandlerVirtAddr
Definition: fs_workload.hh:75
Process::objFile
::Loader::ObjectFile * objFile
Definition: process.hh:213
Process::getBias
Addr getBias()
Definition: process.cc:468
X86ISA::X86_64Process::clone
void clone(ThreadContext *old_tc, ThreadContext *new_tc, Process *process, RegVal flags) override
Definition: process.cc:1010
X86ISA::MISCREG_SF_MASK
@ MISCREG_SF_MASK
Definition: misc.hh:251
X86ISA::MISCREG_CS_ATTR
@ MISCREG_CS_ATTR
Definition: misc.hh:363
name
const std::string & name()
Definition: trace.cc:50
Process::contextIds
std::vector< ContextID > contextIds
Definition: process.hh:160
X86ISA::MISCREG_FS
@ MISCREG_FS
Definition: misc.hh:300
X86ISA::MISCREG_LSTAR
@ MISCREG_LSTAR
Definition: misc.hh:248
X86ISA::MISCREG_CR3
@ MISCREG_CR3
Definition: misc.hh:108
X86ISA::MISCREG_TSG_EFF_BASE
@ MISCREG_TSG_EFF_BASE
Definition: misc.hh:338
ThreadContext::pcState
virtual TheISA::PCState pcState() const =0
X86ISA::I386Process::I386Process
I386Process(ProcessParams *params, ::Loader::ObjectFile *objFile)
Definition: process.cc:119
X86ISA::TSSVirtAddr
const Addr TSSVirtAddr
Definition: fs_workload.hh:72
M5_AT_GID
@ M5_AT_GID
Definition: aux_vector.hh:71
X86ISA::X86_64Process::VSyscallPage::vgettimeofdayOffset
Addr vgettimeofdayOffset
Definition: process.hh:102
X86ISA::MISCREG_SEG_EFF_BASE
static MiscRegIndex MISCREG_SEG_EFF_BASE(int index)
Definition: misc.hh:519
X86ISA::MISCREG_SS
@ MISCREG_SS
Definition: misc.hh:298
X86ISA::X86_64Process::X86_64Process
X86_64Process(ProcessParams *params, ::Loader::ObjectFile *objFile)
Definition: process.cc:98
System::threads
Threads threads
Definition: system.hh:309
X86ISA::SEGMENT_REG_DS
@ SEGMENT_REG_DS
Definition: segment.hh:48
X86ISA::SEGMENT_REG_SS
@ SEGMENT_REG_SS
Definition: segment.hh:47
ArmISA::PageBytes
const Addr PageBytes
Definition: isa_traits.hh:52
aux_vector.hh
X86ISA::NUM_SEGMENTREGS
@ NUM_SEGMENTREGS
Definition: segment.hh:62
PortProxy
This object is a proxy for a port or other object which implements the functional response protocol,...
Definition: port_proxy.hh:80
X86ISA::X86Process::_gdtSize
Addr _gdtSize
Definition: process.hh:62
process.hh
X86ISA::SEGMENT_REG_CS
@ SEGMENT_REG_CS
Definition: segment.hh:46
X86ISA::p
Bitfield< 0 > p
Definition: pagetable.hh:151
std
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:587
X86ISA::X86_64Process::VSyscallPage::vtimeOffset
Addr vtimeOffset
Definition: process.hh:101
X86ISA::I386Process::clone
void clone(ThreadContext *old_tc, ThreadContext *new_tc, Process *process, RegVal flags) override
Definition: process.cc:1018
Process::initState
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
Definition: process.cc:290
roundUp
T roundUp(const T &val, const U &align)
This function is used to align addresses in memory.
Definition: intmath.hh:131
X86ISA::I386Process::vsyscallPage
VSyscallPage vsyscallPage
Definition: process.hh:155
X86ISA::I386Process::VSyscallPage::base
Addr base
Definition: process.hh:136
X86ISA::MISCREG_CR0
@ MISCREG_CR0
Definition: misc.hh:105
X86ISA::X86Process::argsInit
void argsInit(int pageSize, std::vector< AuxVector< IntType > > extraAuxvs)
Definition: process.cc:708
ThreadContext::setMiscReg
virtual void setMiscReg(RegIndex misc_reg, RegVal val)=0
X86ISA::X86_64Process::initState
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
Definition: process.cc:146
X86ISA::installSegDesc
void installSegDesc(ThreadContext *tc, SegmentRegIndex seg, SegDescriptor desc, bool longmode)
Definition: fs_workload.cc:61
X86ISA::SEGMENT_REG_ES
@ SEGMENT_REG_ES
Definition: segment.hh:45
logging.hh
X86ISA::MISCREG_TR
@ MISCREG_TR
Definition: misc.hh:307
X86ISA::SEGMENT_REG_GS
@ SEGMENT_REG_GS
Definition: segment.hh:50
X86ISA::ISTVirtAddr
const Addr ISTVirtAddr
Definition: fs_workload.hh:74
Process::euid
uint64_t euid()
Definition: process.hh:81
Process::getStartPC
Addr getStartPC()
Definition: process.cc:476
X86ISA::MISCREG_IDTR_BASE
@ MISCREG_IDTR_BASE
Definition: misc.hh:324
System::allocPhysPages
Addr allocPhysPages(int npages)
Allocate npages contiguous unused physical pages.
Definition: system.cc:386
X86ISA::MISCREG_SEG_BASE
static MiscRegIndex MISCREG_SEG_BASE(int index)
Definition: misc.hh:512
X86ISA::MISCREG_IDTR_LIMIT
@ MISCREG_IDTR_LIMIT
Definition: misc.hh:358
trace.hh
X86ISA::MISCREG_MXCSR
@ MISCREG_MXCSR
Definition: misc.hh:380
M5_AT_HWCAP
@ M5_AT_HWCAP
Definition: aux_vector.hh:74
ThreadContext::setMiscRegNoEffect
virtual void setMiscRegNoEffect(RegIndex misc_reg, RegVal val)=0
fs_workload.hh
Process::system
System * system
Definition: process.hh:163
Process::uid
uint64_t uid()
Definition: process.hh:80
X86ISA::MISCREG_GS
@ MISCREG_GS
Definition: misc.hh:301
M5_AT_CLKTCK
@ M5_AT_CLKTCK
Definition: aux_vector.hh:75
EmulationPageTable::map
virtual void map(Addr vaddr, Addr paddr, int64_t size, uint64_t flags=0)
Maps a virtual memory region to a physical memory region.
Definition: page_table.cc:45
page_table.hh
copyStringArray
void copyStringArray(std::vector< std::string > &strings, AddrType array_ptr, AddrType data_ptr, const ByteOrder bo, PortProxy &memProxy)
Definition: process_impl.hh:40
X86ISA::MISCREG_CR8
@ MISCREG_CR8
Definition: misc.hh:113
M5_AT_EGID
@ M5_AT_EGID
Definition: aux_vector.hh:72
X86ISA::MISCREG_TSL_ATTR
@ MISCREG_TSL_ATTR
Definition: misc.hh:369
misc.hh
object_file.hh
types.hh
X86ISA::GuestByteOrder
const ByteOrder GuestByteOrder
Definition: isa_traits.hh:45
thread_context.hh
ULL
#define ULL(N)
uint64_t constant
Definition: types.hh:50
X86ISA::seg
Bitfield< 2, 0 > seg
Definition: types.hh:82
X86ISA::MMIORegionVirtAddr
const Addr MMIORegionVirtAddr
Definition: fs_workload.hh:76
Process::memState
std::shared_ptr< MemState > memState
Definition: process.hh:279
RegVal
uint64_t RegVal
Definition: types.hh:168
X86ISA::X86_64Process::VSyscallPage::base
Addr base
Definition: process.hh:99
syscall_desc.hh
X86ISA::MISCREG_TSG_BASE
@ MISCREG_TSG_BASE
Definition: misc.hh:320
X86ISA::StackPointerReg
const int StackPointerReg
Definition: registers.hh:85
M5_AT_PHDR
@ M5_AT_PHDR
Definition: aux_vector.hh:61
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171
bits
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition: bitfield.hh:75

Generated on Wed Sep 30 2020 14:01:59 for gem5 by doxygen 1.8.17