Message ID | 159597947370.12744.8741858978174141331.stgit@bmoger-ubuntu (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | SVM cleanup and INVPCID support for the AMD guests | expand |
On Tue, Jul 28, 2020 at 4:37 PM Babu Moger <babu.moger@amd.com> wrote: > > This is in preparation for the future intercept vector additions. > > Add new functions __set_intercept, __clr_intercept and __is_intercept > using kernel APIs __set_bit, __clear_bit and test_bit espectively. > > Signed-off-by: Babu Moger <babu.moger@amd.com> Sean will probably complain about introducing unused functions, but... Reviewed-by: Jim Mattson <jmattson@google.com>
On 29/07/20 01:37, Babu Moger wrote: > This is in preparation for the future intercept vector additions. > > Add new functions __set_intercept, __clr_intercept and __is_intercept > using kernel APIs __set_bit, __clear_bit and test_bit espectively. > > Signed-off-by: Babu Moger <babu.moger@amd.com> > --- > arch/x86/kvm/svm/svm.h | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h > index 6ac4c00a5d82..3b669718190a 100644 > --- a/arch/x86/kvm/svm/svm.h > +++ b/arch/x86/kvm/svm/svm.h > @@ -217,6 +217,21 @@ static inline struct vmcb *get_host_vmcb(struct vcpu_svm *svm) > return svm->vmcb; > } > > +static inline void __set_intercept(void *addr, int bit) > +{ > + __set_bit(bit, (unsigned long *)addr); > +} > + > +static inline void __clr_intercept(void *addr, int bit) > +{ > + __clear_bit(bit, (unsigned long *)addr); > +} > + > +static inline bool __is_intercept(void *addr, int bit) > +{ > + return test_bit(bit, (unsigned long *)addr); > +} > + Probably worth adding a range check? Paolo > static inline void set_cr_intercept(struct vcpu_svm *svm, int bit) > { > struct vmcb *vmcb = get_host_vmcb(svm); >
> -----Original Message----- > From: kvm-owner@vger.kernel.org <kvm-owner@vger.kernel.org> On Behalf > Of Paolo Bonzini > Sent: Wednesday, July 29, 2020 6:09 PM > To: Moger, Babu <Babu.Moger@amd.com>; vkuznets@redhat.com; > wanpengli@tencent.com; sean.j.christopherson@intel.com; > jmattson@google.com > Cc: kvm@vger.kernel.org; joro@8bytes.org; x86@kernel.org; linux- > kernel@vger.kernel.org; mingo@redhat.com; bp@alien8.de; hpa@zytor.com; > tglx@linutronix.de > Subject: Re: [PATCH v3 01/11] KVM: SVM: Introduce __set_intercept, > __clr_intercept and __is_intercept > > On 29/07/20 01:37, Babu Moger wrote: > > This is in preparation for the future intercept vector additions. > > > > Add new functions __set_intercept, __clr_intercept and __is_intercept > > using kernel APIs __set_bit, __clear_bit and test_bit espectively. > > > > Signed-off-by: Babu Moger <babu.moger@amd.com> > > --- > > arch/x86/kvm/svm/svm.h | 15 +++++++++++++++ > > 1 file changed, 15 insertions(+) > > > > diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index > > 6ac4c00a5d82..3b669718190a 100644 > > --- a/arch/x86/kvm/svm/svm.h > > +++ b/arch/x86/kvm/svm/svm.h > > @@ -217,6 +217,21 @@ static inline struct vmcb *get_host_vmcb(struct > vcpu_svm *svm) > > return svm->vmcb; > > } > > > > +static inline void __set_intercept(void *addr, int bit) { > > + __set_bit(bit, (unsigned long *)addr); } > > + > > +static inline void __clr_intercept(void *addr, int bit) { > > + __clear_bit(bit, (unsigned long *)addr); } > > + > > +static inline bool __is_intercept(void *addr, int bit) { > > + return test_bit(bit, (unsigned long *)addr); } > > + > > Probably worth adding a range check? Paolo, Not sure. It is only called with intercept bits like __set_intercept(addr, INTERCEPT_ xx). All these intercept bits are already accounted for. Thanks > > > static inline void set_cr_intercept(struct vcpu_svm *svm, int bit) { > > struct vmcb *vmcb = get_host_vmcb(svm); > >
diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 6ac4c00a5d82..3b669718190a 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -217,6 +217,21 @@ static inline struct vmcb *get_host_vmcb(struct vcpu_svm *svm) return svm->vmcb; } +static inline void __set_intercept(void *addr, int bit) +{ + __set_bit(bit, (unsigned long *)addr); +} + +static inline void __clr_intercept(void *addr, int bit) +{ + __clear_bit(bit, (unsigned long *)addr); +} + +static inline bool __is_intercept(void *addr, int bit) +{ + return test_bit(bit, (unsigned long *)addr); +} + static inline void set_cr_intercept(struct vcpu_svm *svm, int bit) { struct vmcb *vmcb = get_host_vmcb(svm);
This is in preparation for the future intercept vector additions. Add new functions __set_intercept, __clr_intercept and __is_intercept using kernel APIs __set_bit, __clear_bit and test_bit espectively. Signed-off-by: Babu Moger <babu.moger@amd.com> --- arch/x86/kvm/svm/svm.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+)