From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 1 of 3] Remove use of bit fields in kvm trace structure Date: Mon, 23 Jun 2008 05:33:13 +0300 Message-ID: <485F0B69.4010909@qumranet.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org To: Jerone Young Return-path: Received: from il.qumranet.com ([212.179.150.194]:10738 "EHLO il.qumranet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752641AbYFWCdB (ORCPT ); Sun, 22 Jun 2008 22:33:01 -0400 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: Jerone Young wrote: > > This patch fixes kvmtrace use on big endian systems. When using bit fields the compiler will lay data out in the wrong order expected when laid down into a file. This fixes it by using one variable instead of using bit fields. > > Signed-off-by: Jerone Young > > diff --git a/include/linux/kvm.h b/include/linux/kvm.h > --- a/include/linux/kvm.h > +++ b/include/linux/kvm.h > @@ -311,9 +311,13 @@ struct kvm_s390_interrupt { > > /* This structure represents a single trace buffer record. */ > struct kvm_trace_rec { > - __u32 event:28; > - __u32 extra_u32:3; > - __u32 cycle_in:1; > + /* variable rec_val > + * is split into: > + * bits 0 - 27 -> event id > + * bits 28 -30 -> number of extra data args of size u32 > + * bits 31 -> binary indicator for if tsc is in record > + */ > + __u32 rec_val; > Please use #defines for shifts and masks instead of open-coding. These #defines would be part of the public interface. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic.