x86_cpu.hh (11168:f98eb2da15a4) x86_cpu.hh (11341:bda2c39fd9fd)
1/*
2 * Copyright (c) 2013 Andreas Sandberg
3 * All rights reserved
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 30 unchanged lines hidden (view full) ---

39 * x86 implementation of a KVM-based hardware virtualized CPU.
40 */
41class X86KvmCPU : public BaseKvmCPU
42{
43 public:
44 X86KvmCPU(X86KvmCPUParams *params);
45 virtual ~X86KvmCPU();
46
1/*
2 * Copyright (c) 2013 Andreas Sandberg
3 * All rights reserved
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 30 unchanged lines hidden (view full) ---

39 * x86 implementation of a KVM-based hardware virtualized CPU.
40 */
41class X86KvmCPU : public BaseKvmCPU
42{
43 public:
44 X86KvmCPU(X86KvmCPUParams *params);
45 virtual ~X86KvmCPU();
46
47 void startup();
47 void startup() override;
48
49 /** @{ */
50 void dump() const override;
51 void dumpFpuRegs() const;
52 void dumpIntRegs() const;
53 void dumpSpecRegs() const;
54 void dumpDebugRegs() const;
55 void dumpXCRs() const;
56 void dumpXSave() const;
57 void dumpVCpuEvents() const;
58 void dumpMSRs() const;
59 /** @} */
60
61 protected:
62 typedef std::vector<struct kvm_msr_entry> KvmMSRVector;
63
48
49 /** @{ */
50 void dump() const override;
51 void dumpFpuRegs() const;
52 void dumpIntRegs() const;
53 void dumpSpecRegs() const;
54 void dumpDebugRegs() const;
55 void dumpXCRs() const;
56 void dumpXSave() const;
57 void dumpVCpuEvents() const;
58 void dumpMSRs() const;
59 /** @} */
60
61 protected:
62 typedef std::vector<struct kvm_msr_entry> KvmMSRVector;
63
64 Tick kvmRun(Tick ticks);
64 Tick kvmRun(Tick ticks) override;
65
66 /**
67 * Run the virtual CPU until draining completes.
68 *
69 * In addition to the base functionality provided by
70 * BaseKvmCPU::kvmRunDrain(), this method handles x86-specific
71 * cases where there are pending interrupt events in the virtual
72 * CPU. These are handled by requesting an interrupt window if
73 * interrupts are pending (causing the vCPU to execute until
74 * interrupts can be delivered again).
75 *
76 * @see BaseKvmCPU::kvmRunDrain()
77 * @see archIsDrained()
78 *
79 * @return Number of ticks executed
80 */
65
66 /**
67 * Run the virtual CPU until draining completes.
68 *
69 * In addition to the base functionality provided by
70 * BaseKvmCPU::kvmRunDrain(), this method handles x86-specific
71 * cases where there are pending interrupt events in the virtual
72 * CPU. These are handled by requesting an interrupt window if
73 * interrupts are pending (causing the vCPU to execute until
74 * interrupts can be delivered again).
75 *
76 * @see BaseKvmCPU::kvmRunDrain()
77 * @see archIsDrained()
78 *
79 * @return Number of ticks executed
80 */
81 Tick kvmRunDrain();
81 Tick kvmRunDrain() override;
82
83 /** Wrapper that synchronizes state in kvm_run */
84 Tick kvmRunWrapper(Tick ticks);
85
82
83 /** Wrapper that synchronizes state in kvm_run */
84 Tick kvmRunWrapper(Tick ticks);
85
86 uint64_t getHostCycles() const;
86 uint64_t getHostCycles() const override;
87
88 /**
89 * Methods to access CPUID information using the extended
90 * API. Only available if Kvm::capExtendedCPUID() is true.
91 *
92 * @{
93 */
94 void setCPUID(const struct kvm_cpuid2 &cpuid);

--- 32 unchanged lines hidden (view full) ---

127 void getXCRs(struct kvm_xcrs &regs) const;
128 void setXCRs(const struct kvm_xcrs &regs);
129 void getXSave(struct kvm_xsave &xsave) const;
130 void setXSave(const struct kvm_xsave &xsave);
131 void getVCpuEvents(struct kvm_vcpu_events &events) const;
132 void setVCpuEvents(const struct kvm_vcpu_events &events);
133 /** @} */
134
87
88 /**
89 * Methods to access CPUID information using the extended
90 * API. Only available if Kvm::capExtendedCPUID() is true.
91 *
92 * @{
93 */
94 void setCPUID(const struct kvm_cpuid2 &cpuid);

--- 32 unchanged lines hidden (view full) ---

127 void getXCRs(struct kvm_xcrs &regs) const;
128 void setXCRs(const struct kvm_xcrs &regs);
129 void getXSave(struct kvm_xsave &xsave) const;
130 void setXSave(const struct kvm_xsave &xsave);
131 void getVCpuEvents(struct kvm_vcpu_events &events) const;
132 void setVCpuEvents(const struct kvm_vcpu_events &events);
133 /** @} */
134
135 void updateKvmState();
136 void updateThreadContext();
135 void updateKvmState() override;
136 void updateThreadContext() override;
137
138 /**
139 * Inject pending interrupts from gem5 into the virtual CPU.
140 */
141 void deliverInterrupts();
142
143 /**
144 * Handle x86 legacy IO (in/out)
145 */
137
138 /**
139 * Inject pending interrupts from gem5 into the virtual CPU.
140 */
141 void deliverInterrupts();
142
143 /**
144 * Handle x86 legacy IO (in/out)
145 */
146 Tick handleKvmExitIO();
146 Tick handleKvmExitIO() override;
147
147
148 Tick handleKvmExitIRQWindowOpen();
148 Tick handleKvmExitIRQWindowOpen() override;
149
150 /**
151 * Check if there are pending events in the vCPU that prevents it
152 * from being drained.
153 *
154 * There are cases after interrupt injection where the interrupt
155 * is still pending in the guest. This method detects such cases
156 * and requests additional draining.
157 *
158 * @return False if there are pending events in the guest, True
159 * otherwise.
160 */
149
150 /**
151 * Check if there are pending events in the vCPU that prevents it
152 * from being drained.
153 *
154 * There are cases after interrupt injection where the interrupt
155 * is still pending in the guest. This method detects such cases
156 * and requests additional draining.
157 *
158 * @return False if there are pending events in the guest, True
159 * otherwise.
160 */
161 bool archIsDrained() const;
161 bool archIsDrained() const override;
162
163 private:
164 /**
165 * Support routines to update the state of the KVM CPU from gem5's
166 * state representation.
167 *
168 * @{
169 */

--- 86 unchanged lines hidden ---
162
163 private:
164 /**
165 * Support routines to update the state of the KVM CPU from gem5's
166 * state representation.
167 *
168 * @{
169 */

--- 86 unchanged lines hidden ---