From: "Jan Beulich" Subject: Re: [PATCH v16 01/10] x86: add generic resource (e.g. MSR) access hypercall Date: Fri, 26 Sep 2014 16:40:08 +0100 Message-ID: <5425A4F80200007800039D07@mail.emea.novell.com> References: <1411640350-26155-1-git-send-email-chao.p.peng@linux.intel.com> <1411640350-26155-2-git-send-email-chao.p.peng@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1411640350-26155-2-git-send-email-chao.p.peng@linux.intel.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Chao Peng Cc: keir@xen.org, Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com, George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, Ian.Jackson@eu.citrix.com, xen-devel@lists.xen.org, dgdegra@tycho.nsa.gov List-Id: xen-devel@lists.xenproject.org >>> On 25.09.14 at 12:19, wrote: > + if ( ret ) > + break; > + > + if ( copy_to_guest_offset(ra->data, i, &data, 1) ) As said (I think multiple times) before, considering the earlier copy-in this should be __copy_to_guest_offset(). > + case XENPF_resource_op: > + { > + struct xen_resource_access ra; > + struct xenpf_resource_op *rsc_op = &op->u.resource_op; > + unsigned int cpu = smp_processor_id(); This variable is used just once and hence not warranted. > + > + ra.nr = rsc_op->nr; Apart from the missing upper bound check I think you also ought to drop out (successfully, but without causing any IPIs) when the count is zero. And with you needing to move the copy-in of the array here too, doing some of the error checking here without sending IPIs might be worthwhile too. > --- a/xen/include/xlat.lst > +++ b/xen/include/xlat.lst > @@ -88,6 +88,8 @@ > ? xenpf_enter_acpi_sleep platform.h > ? xenpf_pcpuinfo platform.h > ? xenpf_pcpu_version platform.h > +? xenpf_resource_op platform.h > +? xenpf_resource_data platform.h Alphabetically please. But then again - why is _op being put here anyway? I realize there are a number of bad examples in the compat wrapper source file, but we shouldn't extend this (and you only put a check for _data there anyway). Jan