Skip to content

Commit 4f6c451

Browse files
mingqiangchijren1
authored andcommitted
dm: sync common header file to DM
sync acrn_common.h to device model set secure world enabled flag Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com> Reviewed-by: Yin Fengwei <fengwei.yin@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 2e2f02e commit 4f6c451

File tree

2 files changed

+39
-29
lines changed

2 files changed

+39
-29
lines changed

devicemodel/core/vmmapi.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,12 @@ vm_open(const char *name)
149149
ctx->lowmem_limit = 2 * GB;
150150
ctx->name = (char *)(ctx + 1);
151151
strcpy(ctx->name, name);
152-
create_vm.secure_world_enabled = trusty_enabled;
152+
153+
/* Set trusty enable flag */
154+
if (trusty_enabled)
155+
create_vm.vm_flag |= SECURE_WORLD_ENABLED;
156+
else
157+
create_vm.vm_flag &= (~SECURE_WORLD_ENABLED);
153158

154159
while (retry > 0) {
155160
error = ioctl(ctx->fd, IC_CREATE_VM, &create_vm);

devicemodel/include/public/acrn_common.h

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@
8282
#define REQUEST_READ 0
8383
#define REQUEST_WRITE 1
8484

85+
/* Generic VM flags from guest OS */
86+
#define SECURE_WORLD_ENABLED (1UL<<0) /* Whether secure world is enabled */
87+
8588
/**
8689
* @brief Hypercall
8790
*
@@ -161,29 +164,31 @@ struct acrn_create_vm {
161164
/** created vmid return to VHM. Keep it first field */
162165
int32_t vmid;
163166

164-
/** vcpu numbers this VM want to create */
167+
/** VCPU numbers this VM want to create */
165168
uint32_t vcpu_num;
166169

167170
/** the GUID of this VM */
168171
uint8_t GUID[16];
169172

170-
/** whether Secure World is enabled for this VM */
171-
uint8_t secure_world_enabled;
173+
/* VM flag bits from Guest OS, now used
174+
* SECURE_WORLD_ENABLED (1UL<<0)
175+
*/
176+
uint64_t vm_flag;
172177

173178
/** Reserved for future use*/
174-
uint8_t reserved[31];
179+
uint8_t reserved[24];
175180
} __aligned(8);
176181

177182
/**
178-
* @brief Info to create a vcpu
183+
* @brief Info to create a VCPU
179184
*
180185
* the parameter for HC_CREATE_VCPU hypercall
181186
*/
182187
struct acrn_create_vcpu {
183-
/** the virtual cpu id for the vcpu want to create */
188+
/** the virtual CPU ID for the VCPU created */
184189
uint32_t vcpu_id;
185190

186-
/** the physical cpu id for the vcpu want to create */
191+
/** the physical CPU ID for the VCPU created */
187192
uint32_t pcpu_id;
188193
} __aligned(8);
189194

@@ -193,7 +198,7 @@ struct acrn_create_vcpu {
193198
* the parameter for HC_SET_IOREQ_BUFFER hypercall
194199
*/
195200
struct acrn_set_ioreq_buffer {
196-
/** gpa of per VM request_buffer */
201+
/** guest physical address of VM request_buffer */
197202
uint64_t req_buf;
198203
} __aligned(8);
199204

@@ -204,7 +209,7 @@ struct acrn_set_ioreq_buffer {
204209
#define ACRN_INTR_TYPE_IOAPIC 1
205210

206211
/**
207-
* @brief Info to assert/deassert/pulse a virtual irq line for a VM
212+
* @brief Info to assert/deassert/pulse a virtual IRQ line for a VM
208213
*
209214
* the parameter for HC_ASSERT_IRQLINE/HC_DEASSERT_IRQLINE/HC_PULSE_IRQLINE
210215
* hypercall
@@ -216,76 +221,76 @@ struct acrn_irqline {
216221
/** reserved for alignment padding */
217222
uint32_t reserved;
218223

219-
/** pic irq for ISA type */
224+
/** pic IRQ for ISA type */
220225
uint64_t pic_irq;
221226

222-
/** ioapic irq for IOAPIC & ISA TYPE,
223-
* if -1 then this irq will not be injected
227+
/** ioapic IRQ for IOAPIC & ISA TYPE,
228+
* if -1 then this IRQ will not be injected
224229
*/
225230
uint64_t ioapic_irq;
226231
} __aligned(8);
227232

228233
/**
229-
* @brief Info to inject a msi interrupt for a VM
234+
* @brief Info to inject a MSI interrupt to VM
230235
*
231236
* the parameter for HC_INJECT_MSI hypercall
232237
*/
233238
struct acrn_msi_entry {
234-
/** msi addr[19:12] with dest vcpu id */
239+
/** MSI addr[19:12] with dest VCPU ID */
235240
uint64_t msi_addr;
236241

237-
/** msi data[7:0] with vector */
242+
/** MSI data[7:0] with vector */
238243
uint64_t msi_data;
239244
} __aligned(8);
240245

241246
/**
242-
* @brief Info to inject a nmi interrupt for a VM
247+
* @brief Info to inject a NMI interrupt for a VM
243248
*/
244249
struct acrn_nmi_entry {
245-
/** virtual cpu id to inject */
250+
/** virtual CPU ID to inject */
246251
int64_t vcpu_id;
247252
} __aligned(8);
248253

249254
/**
250-
* @brief Info to remap pass-through pci msi for a VM
255+
* @brief Info to remap pass-through PCI MSI for a VM
251256
*
252257
* the parameter for HC_VM_PCI_MSIX_REMAP hypercall
253258
*/
254259
struct acrn_vm_pci_msix_remap {
255-
/** pass-through pci device virtual BDF# */
260+
/** pass-through PCI device virtual BDF# */
256261
uint16_t virt_bdf;
257262

258-
/** pass-through pci device physical BDF# */
263+
/** pass-through PCI device physical BDF# */
259264
uint16_t phys_bdf;
260265

261-
/** pass-through pci device MSI/x cap control data */
266+
/** pass-through PCI device MSI/MSI-X cap control data */
262267
uint16_t msi_ctl;
263268

264269
/** reserved for alignment padding */
265270
uint16_t reserved;
266271

267-
/** pass-through pci device msi address to remap, which will
272+
/** pass-through PCI device MSI address to remap, which will
268273
* return the caller after remapping
269274
*/
270275
uint64_t msi_addr; /* IN/OUT: msi address to fix */
271276

272-
/** pass-through pci device msi data to remap, which will
277+
/** pass-through PCI device MSI data to remap, which will
273278
* return the caller after remapping
274279
*/
275280
uint32_t msi_data;
276281

277-
/** pass-through pci device is msi or msix
282+
/** pass-through PCI device is MSI or MSI-X
278283
* 0 - MSI, 1 - MSI-X
279284
*/
280285
int32_t msix;
281286

282-
/** if the pass-through pci device is msix, this field contains
287+
/** if the pass-through PCI device is MSI-X, this field contains
283288
* the MSI-X entry table index
284289
*/
285290
int32_t msix_entry_index;
286291

287-
/** if the pass-through pci device is msix, this field contains
288-
* Vector Control for MSI-X Entry, field defined in MSIX spec
292+
/** if the pass-through PCI device is MSI-X, this field contains
293+
* Vector Control for MSI-X Entry, field defined in MSI-X spec
289294
*/
290295
uint32_t vector_ctl;
291296
} __aligned(8);
@@ -294,7 +299,7 @@ struct acrn_vm_pci_msix_remap {
294299
* @brief The guest config pointer offset.
295300
*
296301
* It's designed to support passing DM config data pointer, based on it,
297-
* hypervisor would parse then pass DM defined configration to GUEST vcpu
302+
* hypervisor would parse then pass DM defined configuration to GUEST VCPU
298303
* when booting guest VM.
299304
* the address 0xd0000 here is designed by DM, as it arranged all memory
300305
* layout below 1M, DM should make sure there is no overlap for the address

0 commit comments

Comments
 (0)