From mboxrd@z Thu Jan 1 00:00:00 1970 From: Boris Ostrovsky Subject: Re: [PATCH v4 09/17] x86/VPMU: Interface for setting PMU mode and flags Date: Mon, 27 Jan 2014 10:20:54 -0500 Message-ID: <52E67956.7030503@oracle.com> References: <1390331342-3967-1-git-send-email-boris.ostrovsky@oracle.com> <1390331342-3967-10-git-send-email-boris.ostrovsky@oracle.com> <52E2905D0200007800116BD2@nat28.tlf.novell.com> <52E29F27.50403@oracle.com> <52E6281C020000780011716B@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <52E6281C020000780011716B@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: keir@xen.org, suravee.suthikulpanit@amd.com, andrew.cooper3@citrix.com, eddie.dong@intel.com, dietmar.hahn@ts.fujitsu.com, xen-devel@lists.xen.org, jun.nakajima@intel.com List-Id: xen-devel@lists.xenproject.org On 01/27/2014 03:34 AM, Jan Beulich wrote: >>>> +long do_xenpmu_op(int op, XEN_GUEST_HANDLE_PARAM(xen_pmu_params_t) arg) >>>> +{ >>>> + int ret = -EINVAL; >>>> + xen_pmu_params_t pmu_params; >>>> + uint32_t mode; >>>> + >>>> + switch ( op ) >>>> + { >>>> + case XENPMU_mode_set: >>>> + if ( !is_control_domain(current->domain) ) >>>> + return -EPERM; >>>> + >>>> + if ( copy_from_guest(&pmu_params, arg, 1) ) >>>> + return -EFAULT; >>>> + >>>> + mode = (uint32_t)pmu_params.d.val & XENPMU_MODE_MASK; >>>> + if ( mode & ~XENPMU_MODE_ON ) >>>> + return -EINVAL; >>> Please, if you add a new interface, think carefully about future >>> extension room: Here you ignore the upper 32 bits of .val instead >>> of making sure they're zero, thus making it impossible to assign >>> them some meaning later on. >> I think I can leave this as is for now --- I am storing VPMU mode and >> VPMU features in the Xen-private vpmu_mode, which is a 64-bit value. > You should drop the cast to a 32-bit value at the very least - > "leave this as is for now" reads like you don#t need to make > any changes. mode is stored in the lower 32 bits of vpmu_mode variable a few lines below vpmu_mode &= ~XENPMU_MODE_MASK; // XENPMU_MODE_MASK - 0xffffffff vpmu_mode |= mode; so the cast needs to happen somewhere. I can move it to the line above although I am not sure what difference that would make. -boris