[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 2/6] x86/cpuid: Remove BUG_ON() condition from guest_cpuid()
Include a min() against the appropriate ARRAY_SIZE(), and ASSERT() that max_subleaf is within ARRAY_SIZE(). This is more robust to unexpected problems in a release build of Xen. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- CC: Jan Beulich <JBeulich@xxxxxxxx> --- xen/arch/x86/cpuid.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c index 7b9af1b..076fab3 100644 --- a/xen/arch/x86/cpuid.c +++ b/xen/arch/x86/cpuid.c @@ -856,10 +856,11 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf, switch ( leaf ) { case 0x7: - if ( subleaf > p->feat.max_subleaf ) + ASSERT(p->feat.max_subleaf < ARRAY_SIZE(p->feat.raw)); + if ( subleaf > min_t(uint32_t, p->feat.max_subleaf, + ARRAY_SIZE(p->feat.raw) - 1) ) return; - BUG_ON(subleaf >= ARRAY_SIZE(p->feat.raw)); *res = p->feat.raw[subleaf]; break; -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |