Re: [PATCH 09/13] KVM: x86: save/load state on SMM switch

2015-05-12 Thread Paolo Bonzini
On 13/05/2015 01:56, Bandan Das wrote: > I think it's ok just to replace the offset number with a name. > If you are concerned about readability, we could probably wrap the > "for loops" in the math calculations with a more serious sounding macro > eg. "#define foreach_smm_offset(val, start_offse

Re: [PATCH 09/13] KVM: x86: save/load state on SMM switch

2015-05-12 Thread Bandan Das
Paolo Bonzini writes: > On 06/05/2015 19:55, Bandan Das wrote: >> Valid point. But I would say cryptic names will always be better then >> hex offsets. It's a one time pain in the neck to get the defines >> right. >> >> I found this header - >> ftp://ftp.xskernel.org/soft/linux-src/bochs-2008051

Re: [PATCH 09/13] KVM: x86: save/load state on SMM switch

2015-05-06 Thread Paolo Bonzini
On 06/05/2015 19:55, Bandan Das wrote: > Valid point. But I would say cryptic names will always be better then > hex offsets. It's a one time pain in the neck to get the defines > right. > > I found this header - > ftp://ftp.xskernel.org/soft/linux-src/bochs-20080511/cpu/smm.h > > Maybe we can

Re: [PATCH 09/13] KVM: x86: save/load state on SMM switch

2015-05-06 Thread Bandan Das
Paolo Bonzini writes: .. >>> + >>> + selector = get_smstate(u32, smbase, 0x7fa8 + n * 4); >> Probably a good idea to use #defines for all the offsets here >> and elsewhere. > > Uff, those would be a lot of offsets. It's just as easy to get the > #defines right, as it is to get them right in ge

Re: [PATCH 09/13] KVM: x86: save/load state on SMM switch

2015-05-06 Thread Paolo Bonzini
On 05/05/2015 22:44, Bandan Das wrote: > Paolo Bonzini writes: > >> +static inline bool guest_cpuid_has_longmode(struct kvm_vcpu *vcpu) >> +{ >> +struct kvm_cpuid_entry2 *best; >> + >> +best = kvm_find_cpuid_entry(vcpu, 0x8001, 0); >> +return best && (best->edx & bit(X86_FEATURE

Re: [PATCH 09/13] KVM: x86: save/load state on SMM switch

2015-05-05 Thread Bandan Das
Paolo Bonzini writes: > +static inline bool guest_cpuid_has_longmode(struct kvm_vcpu *vcpu) > +{ > + struct kvm_cpuid_entry2 *best; > + > + best = kvm_find_cpuid_entry(vcpu, 0x8001, 0); > + return best && (best->edx & bit(X86_FEATURE_LM)); > +} > + We could combine all guest_cpui

Re: [PATCH 09/13] KVM: x86: save/load state on SMM switch

2015-05-05 Thread Paolo Bonzini
On 05/05/2015 14:48, Radim Krčmář wrote: > > > +{ > > > +desc->g= (flags >> 15) & 1; > > > +desc->d= (flags >> 14) & 1; > > > +desc->l= (flags >> 13) & 1; > > > +desc->avl = (flags >> 12) & 1; > > > +desc->p= (flags >> 7) & 1; >>>

Re: [PATCH 09/13] KVM: x86: save/load state on SMM switch

2015-05-05 Thread Radim Krčmář
2015-05-05 11:37+0200, Paolo Bonzini: > On 04/05/2015 21:59, Radim Krčmář wrote: > > > The big ugly one. This patch adds support for switching in and out of > > > system management mode, respectively upon receiving KVM_REQ_SMI and upon > > > executing a RSM instruction. Both 32- and 64-bit format

Re: [PATCH 09/13] KVM: x86: save/load state on SMM switch

2015-05-05 Thread Paolo Bonzini
On 04/05/2015 21:59, Radim Krčmář wrote: > > The big ugly one. This patch adds support for switching in and out of > > system management mode, respectively upon receiving KVM_REQ_SMI and upon > > executing a RSM instruction. Both 32- and 64-bit formats are supported > > for the SMM state save a

Re: [PATCH 09/13] KVM: x86: save/load state on SMM switch

2015-05-04 Thread Radim Krčmář
2015-04-30 13:36+0200, Paolo Bonzini: > The big ugly one. This patch adds support for switching in and out of > system management mode, respectively upon receiving KVM_REQ_SMI and upon > executing a RSM instruction. Both 32- and 64-bit formats are supported > for the SMM state save area. > > Sig

[PATCH 09/13] KVM: x86: save/load state on SMM switch

2015-04-30 Thread Paolo Bonzini
The big ugly one. This patch adds support for switching in and out of system management mode, respectively upon receiving KVM_REQ_SMI and upon executing a RSM instruction. Both 32- and 64-bit formats are supported for the SMM state save area. Signed-off-by: Paolo Bonzini --- arch/x86/kvm/cpuid