Skip to content

Commit 0cd8574

Browse files
fyin1lijinxia
authored andcommitted
HV: save the cs limit field for SOS
Save the native cs limit and reuse it for SOS cs limit. To remove the hardcode of cs limit for guest in hypervisor. Tracked-On: #1231 Signed-off-by: Yin Fengwei <fengwei.yin@intel.com> Acked-by: Eddie Dong <Eddie.dong@intel.com>
1 parent 6993fdb commit 0cd8574

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

hypervisor/arch/x86/cpu_save_boot_ctx.S

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ cpu_primary_save_32:
3232
/* Clear Limit field, bit 8-11 */
3333
andl $0x0000f0ff, %ecx
3434
mov %ecx, BOOT_CTX_CS_AR_OFFSET(%eax)
35+
36+
/* Save CS limit field */
37+
mov %cs, %cx
38+
xor %edx, %edx
39+
lsl %ecx, %edx
40+
mov %edx, BOOT_CTX_CS_LIMIT_OFFSET(%eax)
41+
3542
mov %es, BOOT_CTX_ES_SEL_OFFSET(%eax)
3643
mov %ss, BOOT_CTX_SS_SEL_OFFSET(%eax)
3744
mov %ds, BOOT_CTX_DS_SEL_OFFSET(%eax)
@@ -62,6 +69,13 @@ cpu_primary_save_64:
6269
/* Clear Limit field, bit 8-11 */
6370
andl $0x0000f0ff, %ecx
6471
mov %ecx, BOOT_CTX_CS_AR_OFFSET(%r8)
72+
73+
/* Save CS limit field */
74+
mov %cs, %cx
75+
xor %edx, %edx
76+
lsl %ecx, %edx
77+
mov %edx, BOOT_CTX_CS_LIMIT_OFFSET(%r8)
78+
6579
mov %es, BOOT_CTX_ES_SEL_OFFSET(%r8)
6680
mov %ss, BOOT_CTX_SS_SEL_OFFSET(%r8)
6781
mov %ds, BOOT_CTX_DS_SEL_OFFSET(%r8)

hypervisor/include/arch/x86/guest/vm0_boot.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#define BOOT_CTX_FS_SEL_OFFSET 276
2323
#define BOOT_CTX_GS_SEL_OFFSET 278
2424
#define BOOT_CTX_CS_AR_OFFSET 248
25+
#define BOOT_CTX_CS_LIMIT_OFFSET 252
2526
#define BOOT_CTX_EFER_LOW_OFFSET 200
2627
#define BOOT_CTX_EFER_HIGH_OFFSET 204
2728
#define SIZE_OF_BOOT_CTX 296
@@ -40,6 +41,7 @@
4041
#define BOOT_CTX_FS_SEL_OFFSET 276U
4142
#define BOOT_CTX_GS_SEL_OFFSET 278U
4243
#define BOOT_CTX_CS_AR_OFFSET 248U
44+
#define BOOT_CTX_CS_LIMIT_OFFSET 252U
4345
#define BOOT_CTX_EFER_LOW_OFFSET 200U
4446
#define BOOT_CTX_EFER_HIGH_OFFSET 204U
4547
#define SIZE_OF_BOOT_CTX 296U

hypervisor/include/public/acrn_common.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ struct acrn_vcpu_regs {
295295
uint64_t reserved_64[4];
296296

297297
uint32_t cs_ar;
298-
uint32_t reserved_32[4];
298+
uint32_t cs_limit;
299+
uint32_t reserved_32[3];
299300

300301
/* don't change the order of following sel */
301302
uint16_t cs_sel;

0 commit comments

Comments
 (0)