Reviewed-by: Nadav Har'El <[email protected]> On Fri, Mar 3, 2017 at 11:45 AM, 'Sergiy Kibrik' via OSv Development < [email protected]> wrote:
> Features used by various Xen drivers, i.e. xenbus. > > Signed-off-by: Sergiy Kibrik <[email protected]> > --- > arch/aarch64/cpuid.cc | 18 ++++++++++++++++++ > arch/aarch64/cpuid.hh | 9 +++++++++ > arch/aarch64/xen.cc | 28 ++++++++++++++++++++++++++++ > arch/aarch64/xen.hh | 4 ++++ > 4 files changed, 59 insertions(+) > > diff --git a/arch/aarch64/cpuid.cc b/arch/aarch64/cpuid.cc > index 3ac4b24..daf820a 100644 > --- a/arch/aarch64/cpuid.cc > +++ b/arch/aarch64/cpuid.cc > @@ -7,6 +7,7 @@ > > #include "cpuid.hh" > #include "processor.hh" > +#include "xen.hh" > > namespace processor { > > @@ -76,4 +77,21 @@ const std::string& features_str() > return cpuid_str; > } > > +void process_cpuid(features_type& features) > +{ > + xen::get_features(features); > +} > + > +const features_type& features() > +{ > + // features() can be used very early, make sure it is initialized > + static features_type f; > + return f; > +} > + > +features_type::features_type() > +{ > + process_cpuid(*this); > +} > + > } > diff --git a/arch/aarch64/cpuid.hh b/arch/aarch64/cpuid.hh > index 919f62d..a97b605 100644 > --- a/arch/aarch64/cpuid.hh > +++ b/arch/aarch64/cpuid.hh > @@ -28,6 +28,15 @@ enum hwcap_bit { > HWCAP_BIT_N > }; > > +struct features_type { > + features_type(); > + bool xen_clocksource; > + bool xen_vector_callback; > + bool xen_pci; > +}; > + > +extern const features_type& features(); > + > } > > #endif /* CPUID_HH_ */ > diff --git a/arch/aarch64/xen.cc b/arch/aarch64/xen.cc > index 2e4a5fb..39354b0 100644 > --- a/arch/aarch64/xen.cc > +++ b/arch/aarch64/xen.cc > @@ -8,13 +8,16 @@ > #include <osv/types.h> > #include <osv/xen.hh> > #include <xen/interface/xen.h> > +#include <xen/features.h> > #include <bsd/porting/netport.h> /* __dead2 defined here */ > #include <machine/xen/xen-os.h> > #include <xen/evtchn.h> > > #include "arch-dtb.hh" > +#include "cpuid.hh" > > shared_info_t *HYPERVISOR_shared_info; > +uint8_t xen_features[XENFEAT_NR_SUBMAPS * 32]; > > namespace xen { > > @@ -22,6 +25,31 @@ shared_info_t dummy_info; > struct xen_shared_info xen_shared_info __attribute__((aligned(4096))); > constexpr int events_irq = 31; /*FIXME: get from FDT */ > > +/*TODO: this can be common x64/aarch64 code */ > +void get_features(processor::features_type &features) > +{ > + if (!is_xen()) > + return; > + > + for (unsigned int i = 0; i < XENFEAT_NR_SUBMAPS; i++) { > + struct xen_feature_info info = { > + .submap_idx = i, > + }; > + > + if (HYPERVISOR_xen_version(XENVER_get_features, &info) < 0) > + assert(0); > I hate "assert(0)" on several levels, but I see you copied it from the existing x86 code, so ok ;-) > + > + for (int j = 0; j < 32; j++) > + xen_features[i * 32 + j] = !!(info.submap & 1<<j); > + } > + > + features.xen_clocksource = xen_feature(XENFEAT_hvm_safe_pvclock); > + features.xen_vector_callback = xen_feature(XENFEAT_hvm_ > callback_vector); > + > + if (!processor::features().xen_vector_callback) > + evtchn_irq_is_legacy(); > +} > + > static __attribute__((constructor)) void xen_init_irq() > { > if (!is_xen()) > diff --git a/arch/aarch64/xen.hh b/arch/aarch64/xen.hh > index aa5da27..d5046cb 100644 > --- a/arch/aarch64/xen.hh > +++ b/arch/aarch64/xen.hh > @@ -8,8 +8,12 @@ > #ifndef XEN_ARCH_HH > #define XEN_ARCH_HH > > +#include "cpuid.hh" > + > namespace xen { > > +void get_features(processor::features_type &features); > + > } > > #endif /* XEN_ARCH_HH */ > -- > 2.7.4 > > -- > You received this message because you are subscribed to the Google Groups > "OSv Development" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
