x86/svm: Drop svm_segment_register_t

Most SVM code already uses struct segment_register.  Drop the typedef and
adjust the definitions in struct vmcb_struct, and svm_dump_sel().  Introduce
some build-time assertions that struct segment_register from the common
emulation code is usable in struct vmcb_struct.

While making these adjustments, fix some comments to not mix decimal and
hexidecimal offsets, and drop all trailing whitespace in vmcb.h

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
This commit is contained in:
Andrew Cooper committed 2017-07-25 19:56:35 +01:00
1 parent 28d9a9a2d4
commit f93b6575d1
3 files changed
+34 -21

No files matched your search

+1 -1
View File
@@ -21,7 +21,7 @@
#include <asm/msr-index.h>
#include <asm/hvm/svm/svmdebug.h>
static void svm_dump_sel(const char *name, const svm_segment_register_t *s)
static void svm_dump_sel(const char *name, const struct segment_register *s)
{
printk("%s: %04x %04x %08x %016"PRIx64"\n",
name, s->sel, s->attr.bytes, s->limit, s->base);
+16
View File
@@ -310,6 +310,22 @@ void __init setup_vmcb_dump(void)
register_keyhandler('v', vmcb_dump, "dump AMD-V VMCBs", 1);
}
static void __init __maybe_unused build_assertions(void)
{
struct segment_register sreg;
/* Check struct segment_register against the VMCB segment layout. */
BUILD_BUG_ON(sizeof(sreg) != 16);
BUILD_BUG_ON(sizeof(sreg.sel) != 2);
BUILD_BUG_ON(sizeof(sreg.attr) != 2);
BUILD_BUG_ON(sizeof(sreg.limit) != 4);
BUILD_BUG_ON(sizeof(sreg.base) != 8);
BUILD_BUG_ON(offsetof(struct segment_register, sel) != 0);
BUILD_BUG_ON(offsetof(struct segment_register, attr) != 2);
BUILD_BUG_ON(offsetof(struct segment_register, limit) != 4);
BUILD_BUG_ON(offsetof(struct segment_register, base) != 8);
}
/*
* Local variables:
* mode: C
+17 -20
View File
@@ -31,7 +31,7 @@ enum GenericIntercept1bits
GENERAL1_INTERCEPT_SMI = 1 << 2,
GENERAL1_INTERCEPT_INIT = 1 << 3,
GENERAL1_INTERCEPT_VINTR = 1 << 4,
GENERAL1_INTERCEPT_CR0_SEL_WRITE = 1 << 5,
GENERAL1_INTERCEPT_CR0_SEL_WRITE = 1 << 5,
GENERAL1_INTERCEPT_IDTR_READ = 1 << 6,
GENERAL1_INTERCEPT_GDTR_READ = 1 << 7,
GENERAL1_INTERCEPT_LDTR_READ = 1 << 8,
@@ -304,13 +304,10 @@ enum VMEXIT_EXITCODE
VMEXIT_INVALID = -1
};
/* Definition of segment state is borrowed by the generic HVM code. */
typedef struct segment_register svm_segment_register_t;
typedef union
{
u64 bytes;
struct
struct
{
u64 vector: 8;
u64 type: 3;
@@ -324,7 +321,7 @@ typedef union
typedef union
{
u64 bytes;
struct
struct
{
u64 tpr: 8;
u64 irq: 1;
@@ -342,7 +339,7 @@ typedef union
typedef union
{
u64 bytes;
struct
struct
{
u64 type: 1;
u64 rsv0: 1;
@@ -438,23 +435,23 @@ struct vmcb_struct {
u8 guest_ins[15]; /* offset 0xD1 */
u64 res10a[100]; /* offset 0xE0 pad to save area */
svm_segment_register_t es; /* offset 1024 - cleanbit 8 */
svm_segment_register_t cs; /* cleanbit 8 */
svm_segment_register_t ss; /* cleanbit 8 */
svm_segment_register_t ds; /* cleanbit 8 */
svm_segment_register_t fs;
svm_segment_register_t gs;
svm_segment_register_t gdtr; /* cleanbit 7 */
svm_segment_register_t ldtr;
svm_segment_register_t idtr; /* cleanbit 7 */
svm_segment_register_t tr;
struct segment_register es; /* offset 0x400 - cleanbit 8 */
struct segment_register cs; /* cleanbit 8 */
struct segment_register ss; /* cleanbit 8 */
struct segment_register ds; /* cleanbit 8 */
struct segment_register fs;
struct segment_register gs;
struct segment_register gdtr; /* cleanbit 7 */
struct segment_register ldtr;
struct segment_register idtr; /* cleanbit 7 */
struct segment_register tr;
u64 res10[5];
u8 res11[3];
u8 _cpl; /* cleanbit 8 */
u32 res12;
u64 _efer; /* offset 1024 + 0xD0 - cleanbit 5 */
u64 _efer; /* offset 0x400 + 0xD0 - cleanbit 5 */
u64 res13[14];
u64 _cr4; /* offset 1024 + 0x148 - cleanbit 5 */
u64 _cr4; /* offset 0x400 + 0x148 - cleanbit 5 */
u64 _cr3; /* cleanbit 5 */
u64 _cr0; /* cleanbit 5 */
u64 _dr7; /* cleanbit 6 */
@@ -508,7 +505,7 @@ struct arch_svm_struct {
uint64_t guest_sysenter_cs;
uint64_t guest_sysenter_esp;
uint64_t guest_sysenter_eip;
/* AMD lightweight profiling MSR */
uint64_t guest_lwp_cfg; /* guest version */
uint64_t cpu_lwp_cfg; /* CPU version */
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.